aboutsummaryrefslogtreecommitdiff
path: root/migrations/1_schema.up.sql
blob: 2f8bc0403848d8e581bb171d090eeeed7bd24682 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
CREATE TABLE IF NOT EXISTS "users" (
    "id" INTEGER,
    "email" TEXT NOT NULL,
    "password" TEXT NOT NULL,
    "username" TEXT NOT NULL,
    "photo" TEXT,
    "role" INTEGER DEFAULT(0),
    PRIMARY KEY ("id" AUTOINCREMENT),
    UNIQUE ("email" COLLATE NOCASE),
    UNIQUE ("username" COLLATE NOCASE)
);

CREATE TABLE IF NOT EXISTS "nodes" (
    "id" INTEGER,
    "type" INTEGER,
    "text" TEXT,
    "author_id" INTEGER NOT NULL,
    "parent_id" INTEGER,
    "created_at" INTEGER NOT NULL,
    "updated_at" INTEGER NOT NULL,
    "deleted_at" INTEGER,
    "permission" INTEGER,
    PRIMARY KEY ("id" AUTOINCREMENT),
    FOREIGN KEY ("author_id") REFERENCES "users" ("id"),
    FOREIGN KEY ("parent_id") REFERENCES "posts" ("id")
);