|
@@ -0,0 +1,130 @@
|
|
1
|
+-- Adminer 4.2.4 SQLite 3 dump
|
|
2
|
+
|
|
3
|
+PRAGMA foreign_keys = off;
|
|
4
|
+
|
|
5
|
+DROP TABLE IF EXISTS "categories";
|
|
6
|
+CREATE TABLE "categories" (
|
|
7
|
+ "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
8
|
+ "name" text(255) NOT NULL,
|
|
9
|
+ "icon" data NULL
|
|
10
|
+);
|
|
11
|
+
|
|
12
|
+INSERT INTO "categories" ("id", "name", "icon") VALUES (1, 'announcement', NULL);
|
|
13
|
+INSERT INTO "categories" ("id", "name", "icon") VALUES (2, 'article', NULL);
|
|
14
|
+
|
|
15
|
+DROP TABLE IF EXISTS "comments";
|
|
16
|
+CREATE TABLE "comments" (
|
|
17
|
+ "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
18
|
+ "post_id" integer NOT NULL,
|
|
19
|
+ "message" text NOT NULL,
|
|
20
|
+ FOREIGN KEY ("post_id") REFERENCES "posts" ("id")
|
|
21
|
+);
|
|
22
|
+
|
|
23
|
+CREATE INDEX "comments_post_id" ON "comments" ("post_id");
|
|
24
|
+
|
|
25
|
+INSERT INTO "comments" ("id", "post_id", "message") VALUES (1, 1, 'great');
|
|
26
|
+INSERT INTO "comments" ("id", "post_id", "message") VALUES (2, 1, 'fantastic');
|
|
27
|
+INSERT INTO "comments" ("id", "post_id", "message") VALUES (3, 2, 'thank you');
|
|
28
|
+INSERT INTO "comments" ("id", "post_id", "message") VALUES (4, 2, 'awesome');
|
|
29
|
+
|
|
30
|
+DROP TABLE IF EXISTS "post_tags";
|
|
31
|
+CREATE TABLE "post_tags" (
|
|
32
|
+ "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
33
|
+ "post_id" integer NOT NULL,
|
|
34
|
+ "tag_id" integer NOT NULL,
|
|
35
|
+ FOREIGN KEY ("tag_id") REFERENCES "tags" ("id"),
|
|
36
|
+ FOREIGN KEY ("post_id") REFERENCES "posts" ("id") ON DELETE RESTRICT ON UPDATE RESTRICT
|
|
37
|
+);
|
|
38
|
+
|
|
39
|
+CREATE UNIQUE INDEX "post_tags_post_id_tag_id" ON "post_tags" ("post_id", "tag_id");
|
|
40
|
+
|
|
41
|
+INSERT INTO "post_tags" ("id", "post_id", "tag_id") VALUES (1, 1, 1);
|
|
42
|
+INSERT INTO "post_tags" ("id", "post_id", "tag_id") VALUES (2, 1, 2);
|
|
43
|
+INSERT INTO "post_tags" ("id", "post_id", "tag_id") VALUES (3, 2, 1);
|
|
44
|
+INSERT INTO "post_tags" ("id", "post_id", "tag_id") VALUES (4, 2, 2);
|
|
45
|
+
|
|
46
|
+DROP TABLE IF EXISTS "posts";
|
|
47
|
+CREATE TABLE "posts" (
|
|
48
|
+ "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
49
|
+ "user_id" integer NOT NULL,
|
|
50
|
+ "category_id" integer NOT NULL,
|
|
51
|
+ "content" text NOT NULL,
|
|
52
|
+ FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE RESTRICT,
|
|
53
|
+ FOREIGN KEY ("category_id") REFERENCES "categories" ("id") ON DELETE RESTRICT ON UPDATE RESTRICT
|
|
54
|
+);
|
|
55
|
+
|
|
56
|
+CREATE INDEX "posts_user_id" ON "posts" ("user_id");
|
|
57
|
+
|
|
58
|
+CREATE INDEX "posts_category_id" ON "posts" ("category_id");
|
|
59
|
+
|
|
60
|
+INSERT INTO "posts" ("id", "user_id", "category_id", "content") VALUES (1, 1, 1, 'blog started');
|
|
61
|
+INSERT INTO "posts" ("id", "user_id", "category_id", "content") VALUES (2, 1, 2, 'It works!');
|
|
62
|
+
|
|
63
|
+DROP TABLE IF EXISTS "tags";
|
|
64
|
+CREATE TABLE "tags" (
|
|
65
|
+ "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
66
|
+ "name" text(255) NOT NULL
|
|
67
|
+);
|
|
68
|
+
|
|
69
|
+INSERT INTO "tags" ("id", "name") VALUES (1, 'funny');
|
|
70
|
+INSERT INTO "tags" ("id", "name") VALUES (2, 'important');
|
|
71
|
+
|
|
72
|
+DROP TABLE IF EXISTS "users";
|
|
73
|
+CREATE TABLE "users" (
|
|
74
|
+ "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
75
|
+ "username" text(255) NOT NULL,
|
|
76
|
+ "password" text(255) NOT NULL,
|
|
77
|
+ "location" geometry NULL
|
|
78
|
+);
|
|
79
|
+
|
|
80
|
+INSERT INTO "users" ("id", "username", "password", "location") VALUES (1, 'user1', 'pass1', NULL);
|
|
81
|
+INSERT INTO "users" ("id", "username", "password", "location") VALUES (2, 'user2', 'pass2', NULL);
|
|
82
|
+
|
|
83
|
+DROP TABLE IF EXISTS "countries";
|
|
84
|
+CREATE TABLE "countries" (
|
|
85
|
+ "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
86
|
+ "name" text(255) NOT NULL,
|
|
87
|
+ "shape" geometry NOT NULL
|
|
88
|
+);
|
|
89
|
+
|
|
90
|
+INSERT INTO "countries" ("id", "name", "shape") VALUES (1, 'Left', 'POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))');
|
|
91
|
+INSERT INTO "countries" ("id", "name", "shape") VALUES (2, 'Right', 'POLYGON ((70 10, 80 40, 60 40, 50 20, 70 10))');
|
|
92
|
+
|
|
93
|
+DROP TABLE IF EXISTS "events";
|
|
94
|
+CREATE TABLE "events" (
|
|
95
|
+ "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
96
|
+ "name" text(255) NOT NULL,
|
|
97
|
+ "datetime" datetime NOT NULL,
|
|
98
|
+ "visitors" integer NOT NULL
|
|
99
|
+);
|
|
100
|
+
|
|
101
|
+INSERT INTO "events" ("id", "name", "datetime", "visitors") VALUES (1, 'Launch', '2016-01-01 13:01:01', 0);
|
|
102
|
+
|
|
103
|
+DROP VIEW IF EXISTS "tag_usage";
|
|
104
|
+CREATE VIEW "tag_usage" AS select "name", count("name") AS "count" from "tags", "post_tags" where "tags"."id" = "post_tags"."tag_id" group by "name" order by "count" desc, "name";
|
|
105
|
+
|
|
106
|
+DROP TABLE IF EXISTS "products";
|
|
107
|
+CREATE TABLE "products" (
|
|
108
|
+ "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
109
|
+ "name" text(255) NOT NULL,
|
|
110
|
+ "price" text(12) NOT NULL,
|
|
111
|
+ "properties" json NOT NULL,
|
|
112
|
+ "created_at" datetime NOT NULL,
|
|
113
|
+ "deleted_at" datetime NULL
|
|
114
|
+);
|
|
115
|
+
|
|
116
|
+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');
|
|
117
|
+
|
|
118
|
+DROP TABLE IF EXISTS "barcodes";
|
|
119
|
+CREATE TABLE "barcodes" (
|
|
120
|
+ "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
121
|
+ "product_id" integer NOT NULL,
|
|
122
|
+ "hex" text(255) NOT NULL,
|
|
123
|
+ "bin" binary(255) NOT NULL
|
|
124
|
+);
|
|
125
|
+
|
|
126
|
+INSERT INTO "barcodes" ("id", "product_id", "hex", "bin") VALUES (1, 1, '00ff01', 'AP8B');
|
|
127
|
+
|
|
128
|
+PRAGMA foreign_keys = on;
|
|
129
|
+
|
|
130
|
+--
|