@@ -19,8 +19,8 @@ CREATE TABLE "comments" (
19
19
" post_id" integer NOT NULL ,
20
20
" message" text NOT NULL ,
21
21
" category_id" integer NOT NULL ,
22
- FOREIGN KEY (" post_id" ) REFERENCES " posts" (" id" ),
23
- FOREIGN KEY (" category_id" ) REFERENCES " categories" (" id" )
22
+ FOREIGN KEY (" post_id" ) REFERENCES " posts" (" id" ) ON DELETE RESTRICT ON UPDATE RESTRICT ,
23
+ FOREIGN KEY (" category_id" ) REFERENCES " categories" (" id" ) ON DELETE RESTRICT ON UPDATE RESTRICT
24
24
);
25
25
26
26
CREATE INDEX "comments_post_id " ON " comments" (" post_id" );
@@ -31,22 +31,6 @@ INSERT INTO "comments" ("id", "post_id", "message", "category_id") VALUES (2, 1,
31
31
INSERT INTO " comments" (" id" , " post_id" , " message" , " category_id" ) VALUES (3 , 2 , ' thank you' , 3 );
32
32
INSERT INTO " comments" (" id" , " post_id" , " message" , " category_id" ) VALUES (4 , 2 , ' awesome' , 3 );
33
33
34
- DROP TABLE IF EXISTS " post_tags" ;
35
- CREATE TABLE "post_tags " (
36
- " id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
37
- " post_id" integer NOT NULL ,
38
- " tag_id" integer NOT NULL ,
39
- FOREIGN KEY (" tag_id" ) REFERENCES " tags" (" id" ),
40
- FOREIGN KEY (" post_id" ) REFERENCES " posts" (" id" ) ON DELETE RESTRICT ON UPDATE RESTRICT
41
- );
42
-
43
- CREATE UNIQUE INDEX "post_tags_post_id_tag_id " ON " post_tags" (" post_id" , " tag_id" );
44
-
45
- INSERT INTO " post_tags" (" id" , " post_id" , " tag_id" ) VALUES (1 , 1 , 1 );
46
- INSERT INTO " post_tags" (" id" , " post_id" , " tag_id" ) VALUES (2 , 1 , 2 );
47
- INSERT INTO " post_tags" (" id" , " post_id" , " tag_id" ) VALUES (3 , 2 , 1 );
48
- INSERT INTO " post_tags" (" id" , " post_id" , " tag_id" ) VALUES (4 , 2 , 2 );
49
-
50
34
DROP TABLE IF EXISTS " posts" ;
51
35
CREATE TABLE "posts " (
52
36
" id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
@@ -64,6 +48,22 @@ CREATE INDEX "posts_category_id" ON "posts" ("category_id");
64
48
INSERT INTO " posts" (" id" , " user_id" , " category_id" , " content" ) VALUES (1 , 1 , 1 , ' blog started' );
65
49
INSERT INTO " posts" (" id" , " user_id" , " category_id" , " content" ) VALUES (2 , 1 , 2 , ' It works!' );
66
50
51
+ DROP TABLE IF EXISTS " post_tags" ;
52
+ CREATE TABLE "post_tags " (
53
+ " id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
54
+ " post_id" integer NOT NULL ,
55
+ " tag_id" integer NOT NULL ,
56
+ FOREIGN KEY (" tag_id" ) REFERENCES " tags" (" id" ) ON DELETE RESTRICT ON UPDATE RESTRICT,
57
+ FOREIGN KEY (" post_id" ) REFERENCES " posts" (" id" ) ON DELETE RESTRICT ON UPDATE RESTRICT
58
+ );
59
+
60
+ CREATE UNIQUE INDEX "post_tags_post_id_tag_id " ON " post_tags" (" post_id" , " tag_id" );
61
+
62
+ INSERT INTO " post_tags" (" id" , " post_id" , " tag_id" ) VALUES (1 , 1 , 1 );
63
+ INSERT INTO " post_tags" (" id" , " post_id" , " tag_id" ) VALUES (2 , 1 , 2 );
64
+ INSERT INTO " post_tags" (" id" , " post_id" , " tag_id" ) VALUES (3 , 2 , 1 );
65
+ INSERT INTO " post_tags" (" id" , " post_id" , " tag_id" ) VALUES (4 , 2 , 2 );
66
+
67
67
DROP TABLE IF EXISTS " tags" ;
68
68
CREATE TABLE "tags " (
69
69
" id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
@@ -83,7 +83,7 @@ CREATE TABLE "users" (
83
83
);
84
84
85
85
INSERT INTO " users" (" id" , " username" , " password" , " location" ) VALUES (1 , ' user1' , ' pass1' , NULL );
86
- INSERT INTO " users" (" id" , " username" , " password" , " location" ) VALUES (2 , ' user2' , ' pass2 ' , NULL );
86
+ INSERT INTO " users" (" id" , " username" , " password" , " location" ) VALUES (2 , ' user2' , ' $2y$10$cg7/nswxVZ0cmVIsMB/pVOh1OfcHScBJGq7Xu4KF9dFEQgRZ8HWe. ' , NULL );
87
87
88
88
DROP TABLE IF EXISTS " countries" ;
89
89
CREATE TABLE "countries " (
@@ -108,8 +108,8 @@ DROP TABLE IF EXISTS "events";
108
108
CREATE TABLE "events " (
109
109
" id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
110
110
" name" varchar (255 ) NOT NULL ,
111
- " datetime" datetime NOT NULL ,
112
- " visitors" integer NOT NULL
111
+ " datetime" datetime,
112
+ " visitors" bigint
113
113
);
114
114
115
115
INSERT INTO " events" (" id" , " name" , " datetime" , " visitors" ) VALUES (1 , ' Launch' , ' 2016-01-01 13:01:01' , 0 );
@@ -129,15 +129,17 @@ CREATE TABLE "products" (
129
129
130
130
INSERT INTO " products" (" id" , " name" , " price" , " properties" , " created_at" ) VALUES (1 , ' Calculator' , ' 23.01' , ' {"depth":false,"model":"TRX-120","width":100,"height":null}' , ' 1970-01-01 01:01:01' );
131
131
132
+ DROP TABLE IF EXISTS " barcodes2" ;
132
133
DROP TABLE IF EXISTS " barcodes" ;
133
134
CREATE TABLE "barcodes " (
134
135
" id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
135
136
" product_id" integer NOT NULL ,
136
137
" hex" varchar (255 ) NOT NULL ,
137
- " bin" blob NOT NULL
138
+ " bin" blob NOT NULL ,
139
+ " ip_address" varchar (15 )
138
140
);
139
141
140
- INSERT INTO " barcodes" (" id" , " product_id" , " hex" , " bin" ) VALUES (1 , 1 , ' 00ff01' , ' AP8B' );
142
+ INSERT INTO " barcodes" (" id" , " product_id" , " hex" , " bin" , " ip_address " ) VALUES (1 , 1 , ' 00ff01' , ' AP8B' , ' 127.0.0.1 ' );
141
143
142
144
DROP TABLE IF EXISTS " kunsthåndværk" ;
143
145
CREATE TABLE " kunsthåndværk" (
@@ -151,6 +153,20 @@ CREATE TABLE "kunsthåndværk" (
151
153
INSERT INTO " kunsthåndværk" (" id" , " Umlauts ä_ö_ü-COUNT" , " user_id" , " invisible" ) VALUES (' e42c77c6-06a4-4502-816c-d112c7142e6d' , 1 , 1 , NULL );
152
154
INSERT INTO " kunsthåndværk" (" id" , " Umlauts ä_ö_ü-COUNT" , " user_id" , " invisible" ) VALUES (' e31ecfe6-591f-4660-9fbd-1a232083037f' , 2 , 2 , NULL );
153
155
156
+ DROP TABLE IF EXISTS " invisibles" ;
157
+ CREATE TABLE "invisibles " (
158
+ " id" varchar (36 ) NOT NULL PRIMARY KEY
159
+ );
160
+
161
+ INSERT INTO " invisibles" (" id" ) VALUES (' e42c77c6-06a4-4502-816c-d112c7142e6d' );
162
+
163
+ DROP TABLE IF EXISTS " nopk" ;
164
+ CREATE TABLE "nopk " (
165
+ " id" varchar (36 ) NOT NULL
166
+ );
167
+
168
+ INSERT INTO " nopk" (" id" ) VALUES (' e42c77c6-06a4-4502-816c-d112c7142e6d' );
169
+
154
170
PRAGMA foreign_keys = on ;
155
171
156
172
--
0 commit comments