Ver código fonte

Update schema errors

David Ginzberg 7 anos atrás
pai
commit
2ec7092e7b
1 arquivos alterados com 11 adições e 9 exclusões
  1. 11
    9
      src/main/resources/schema-h2.sql

+ 11
- 9
src/main/resources/schema-h2.sql Ver arquivo

@@ -1,4 +1,4 @@
1
-DROP TABLE PERSON;
1
+DROP TABLE IF EXISTS PERSON;
2 2
 
3 3
 CREATE TABLE PERSON (
4 4
   ID INT NOT NULL AUTO_INCREMENT,
@@ -8,7 +8,7 @@ CREATE TABLE PERSON (
8 8
   BIRTHDAY DATE DEFAULT NULL,
9 9
   PRIMARY KEY (ID));
10 10
 
11
-DROP TABLE HOME;
11
+DROP TABLE IF EXISTS HOME;
12 12
 
13 13
 CREATE TABLE HOME (
14 14
   ID INT NOT NULL AUTO_INCREMENT,
@@ -17,7 +17,7 @@ CREATE TABLE HOME (
17 17
   PRIMARY KEY (ID)
18 18
 );
19 19
 
20
-DROP TABLE movies;
20
+DROP TABLE IF EXISTS movies;
21 21
 
22 22
 CREATE TABLE movies (
23 23
   id INT PRIMARY KEY AUTO_INCREMENT,
@@ -28,10 +28,9 @@ CREATE TABLE movies (
28 28
   rating VARCHAR2(10)
29 29
 );
30 30
 
31
-
32 31
 -- Tables for in-class example
33 32
 
34
-DROP TABLE cars;
33
+DROP TABLE IF EXISTS cars;
35 34
 
36 35
 CREATE TABLE cars (
37 36
   id INT NOT NULL AUTO_INCREMENT,
@@ -39,17 +38,20 @@ CREATE TABLE cars (
39 38
   model VARCHAR2(50) NOT NULL DEFAULT '',
40 39
   year VARCHAR2(5) NOT NULL DEFAULT '01907',
41 40
   PRIMARY KEY (id),
42
-  CONSTRAINT 'unique_make_model_year' UNIQUE (make, model, year)
41
+  CONSTRAINT unique_make_model_year UNIQUE (make, model, year)
42
+
43 43
 );
44 44
 
45
-DROP TABLE auto_prices;
45
+DROP TABLE IF EXISTS auto_prices;
46 46
 
47 47
 CREATE TABLE auto_prices (
48 48
   id INT PRIMARY KEY AUTO_INCREMENT,
49
-  car_id INT REFERENCES car(id),
49
+  car_id INT REFERENCES cars(id),
50 50
   package VARCHAR2(15) NOT NULL,
51 51
   price NUMBER(10,2) NOT NULL CHECK(price > 0),
52
-  CONSTRAINT 'unique_package_per_car' UNIQUE (car_id, package)
52
+  CONSTRAINT unique_package_per_car UNIQUE (car_id, package)
53
+
54
+
53 55
 );
54 56
 
55 57
 DROP SEQUENCE hibernate_sequence;