From e9a64f3b41b5eae47dec7c0ecfd1caae83136abc Mon Sep 17 00:00:00 2001
From: Alexander NeonXP Kiryukhin <i@neonxp.ru>
Date: Sat, 20 Jul 2024 21:56:37 +0300
Subject: initial

---
 migrations/1_schema.up.sql | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 migrations/1_schema.up.sql

(limited to 'migrations/1_schema.up.sql')

diff --git a/migrations/1_schema.up.sql b/migrations/1_schema.up.sql
new file mode 100644
index 0000000..2f8bc04
--- /dev/null
+++ b/migrations/1_schema.up.sql
@@ -0,0 +1,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")
+);
+
-- 
cgit v1.2.3

