Browse Source

Update schema errors

David Ginzberg 7 years ago
parent
commit
2ec7092e7b
1 changed files with 11 additions and 9 deletions
  1. 11
    9
      src/main/resources/schema-h2.sql

+ 11
- 9
src/main/resources/schema-h2.sql View File

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