Skip to content

Commit 3e68bc6

Browse files
committed
Update fixture data
1 parent 6ca92f1 commit 3e68bc6

File tree

1 file changed

+39
-23
lines changed

1 file changed

+39
-23
lines changed

tests/fixtures/blog_sqlite.sql

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ CREATE TABLE "comments" (
1919
"post_id" integer NOT NULL,
2020
"message" text NOT NULL,
2121
"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
2424
);
2525

2626
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,
3131
INSERT INTO "comments" ("id", "post_id", "message", "category_id") VALUES (3, 2, 'thank you', 3);
3232
INSERT INTO "comments" ("id", "post_id", "message", "category_id") VALUES (4, 2, 'awesome', 3);
3333

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-
5034
DROP TABLE IF EXISTS "posts";
5135
CREATE TABLE "posts" (
5236
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
@@ -64,6 +48,22 @@ CREATE INDEX "posts_category_id" ON "posts" ("category_id");
6448
INSERT INTO "posts" ("id", "user_id", "category_id", "content") VALUES (1, 1, 1, 'blog started');
6549
INSERT INTO "posts" ("id", "user_id", "category_id", "content") VALUES (2, 1, 2, 'It works!');
6650

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+
6767
DROP TABLE IF EXISTS "tags";
6868
CREATE TABLE "tags" (
6969
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
@@ -83,7 +83,7 @@ CREATE TABLE "users" (
8383
);
8484

8585
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);
8787

8888
DROP TABLE IF EXISTS "countries";
8989
CREATE TABLE "countries" (
@@ -108,8 +108,8 @@ DROP TABLE IF EXISTS "events";
108108
CREATE TABLE "events" (
109109
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
110110
"name" varchar(255) NOT NULL,
111-
"datetime" datetime NOT NULL,
112-
"visitors" integer NOT NULL
111+
"datetime" datetime,
112+
"visitors" bigint
113113
);
114114

115115
INSERT INTO "events" ("id", "name", "datetime", "visitors") VALUES (1, 'Launch', '2016-01-01 13:01:01', 0);
@@ -129,15 +129,17 @@ CREATE TABLE "products" (
129129

130130
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');
131131

132+
DROP TABLE IF EXISTS "barcodes2";
132133
DROP TABLE IF EXISTS "barcodes";
133134
CREATE TABLE "barcodes" (
134135
"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
135136
"product_id" integer NOT NULL,
136137
"hex" varchar(255) NOT NULL,
137-
"bin" blob NOT NULL
138+
"bin" blob NOT NULL,
139+
"ip_address" varchar(15)
138140
);
139141

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');
141143

142144
DROP TABLE IF EXISTS "kunsthåndværk";
143145
CREATE TABLE "kunsthåndværk" (
@@ -151,6 +153,20 @@ CREATE TABLE "kunsthåndværk" (
151153
INSERT INTO "kunsthåndværk" ("id", "Umlauts ä_ö_ü-COUNT", "user_id", "invisible") VALUES ('e42c77c6-06a4-4502-816c-d112c7142e6d', 1, 1, NULL);
152154
INSERT INTO "kunsthåndværk" ("id", "Umlauts ä_ö_ü-COUNT", "user_id", "invisible") VALUES ('e31ecfe6-591f-4660-9fbd-1a232083037f', 2, 2, NULL);
153155

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+
154170
PRAGMA foreign_keys = on;
155171

156172
--

0 commit comments

Comments
 (0)