webmcp
view demo-app/db/schema.sql @ 468:225d6b2ac050
Fixed inline documentation of encode.file_path(...)
author | jbe |
---|---|
date | Fri Apr 21 16:30:41 2017 +0200 (2017-04-21) |
parents | 9fdfb27f8e67 |
children |
line source
1 -- only needed for database driven tempstore (see application config)
2 CREATE TABLE "tempstore" (
3 "key" TEXT PRIMARY KEY,
4 "data" BYTEA NOT NULL );
6 -- Attention: USER is a reserved word in PostgreSQL. We use it anyway in
7 -- this example. Don't forget the double quotes where neccessary.
8 CREATE TABLE "user" (
9 "id" SERIAL8 PRIMARY KEY,
10 "ident" TEXT NOT NULL,
11 "password" TEXT,
12 "name" TEXT,
13 "lang" TEXT,
14 "write_priv" BOOLEAN NOT NULL DEFAULT FALSE,
15 "admin" BOOLEAN NOT NULL DEFAULT FALSE );
17 CREATE TABLE "session" (
18 "ident" TEXT PRIMARY KEY,
19 "csrf_secret" TEXT NOT NULL,
20 "expiry" TIMESTAMPTZ NOT NULL DEFAULT NOW() + '24 hours',
21 "user_id" INT8 REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE );
23 CREATE TABLE "media_type" (
24 "id" SERIAL8 PRIMARY KEY,
25 "name" TEXT NOT NULL,
26 "description" TEXT );
28 CREATE TABLE "genre" (
29 "id" SERIAL8 PRIMARY KEY,
30 "name" TEXT NOT NULL,
31 "description" TEXT );
33 CREATE TABLE "medium" (
34 "id" SERIAL8 PRIMARY KEY,
35 "media_type_id" INT8 NOT NULL REFERENCES "media_type" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
36 "name" TEXT NOT NULL,
37 "copyprotected" BOOLEAN NOT NULL );
39 CREATE TABLE "classification" (
40 PRIMARY KEY ("medium_id", "genre_id"),
41 "medium_id" INT8 REFERENCES "medium" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
42 "genre_id" INT8 REFERENCES "genre" ("id") ON DELETE CASCADE ON UPDATE CASCADE );
44 CREATE TABLE "track" (
45 "id" SERIAL8 PRIMARY KEY,
46 "medium_id" INT8 NOT NULL REFERENCES "medium" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
47 "position" INT8 NOT NULL,
48 "name" TEXT NOT NULL,
49 "description" TEXT,
50 "duration" INTERVAL,
51 UNIQUE ("medium_id", "position") );
53 INSERT INTO "user" ("ident", "password", "name", "write_priv", "admin")
54 VALUES ('admin', 'admin', 'Administrator', true, true);
56 INSERT INTO "user" ("ident", "password", "name", "write_priv", "admin")
57 VALUES ('user', 'User', 'User', true, false);
59 INSERT INTO "user" ("ident", "password", "name", "write_priv", "admin")
60 VALUES ('anon', 'anon', 'Anonymous', false, false);
62 INSERT INTO "media_type" ("name", "description") VALUES ('CD', '');
63 INSERT INTO "media_type" ("name", "description") VALUES ('Tape', '');
65 INSERT INTO "genre" ("name", "description") VALUES ('Klassik', '');
66 INSERT INTO "genre" ("name", "description") VALUES ('Gospel', '');
67 INSERT INTO "genre" ("name", "description") VALUES ('Jazz', '');
68 INSERT INTO "genre" ("name", "description") VALUES ('Traditional', '');
69 INSERT INTO "genre" ("name", "description") VALUES ('Latin', '');
70 INSERT INTO "genre" ("name", "description") VALUES ('Blues', '');
71 INSERT INTO "genre" ("name", "description") VALUES ('Rhythm & blues', '');
72 INSERT INTO "genre" ("name", "description") VALUES ('Funk', '');
73 INSERT INTO "genre" ("name", "description") VALUES ('Rock', '');
74 INSERT INTO "genre" ("name", "description") VALUES ('Pop', '');
75 INSERT INTO "genre" ("name", "description") VALUES ('Country', '');
76 INSERT INTO "genre" ("name", "description") VALUES ('Electronic', '');
77 INSERT INTO "genre" ("name", "description") VALUES ('Ska / Reggea', '');
78 INSERT INTO "genre" ("name", "description") VALUES ('Hip hop / Rap', '');