summaryrefslogtreecommitdiff
path: root/migrations/20250819.php
diff options
context:
space:
mode:
Diffstat (limited to 'migrations/20250819.php')
-rw-r--r--migrations/20250819.php45
1 files changed, 45 insertions, 0 deletions
diff --git a/migrations/20250819.php b/migrations/20250819.php
new file mode 100644
index 0000000..cfd0f65
--- /dev/null
+++ b/migrations/20250819.php
@@ -0,0 +1,45 @@
+<?php
+
+use App\Database;
+
+Database::getInstance()->query(<<<SQL
+ create table if not exists "migrations" (
+ "id" bigserial primary key,
+ "name" varchar(64) not null
+ );
+SQL);
+
+Database::getInstance()->query(<<<SQL
+ create table if not exists "users" (
+ "id" varchar(255) primary key,
+ "password" varchar(255),
+
+ "name" varchar(255),
+ "is_deactivated" bool
+ );
+SQL);
+
+Database::getInstance()->query(<<<SQL
+ create table if not exists "devices" (
+ "id" varchar(255) not null,
+ "name" varchar(255) not null,
+
+ "user_id" varchar(255) references users(id) not null,
+
+ primary key (user_id, id)
+ );
+SQL);
+
+Database::getInstance()->query(<<<SQL
+ create table if not exists "tokens" (
+ "id" bigserial primary key,
+
+ "access_token" varchar(255) not null,
+ "refresh_token" varchar(255) not null,
+
+ "user_id" varchar(255) not null,
+ "device_id" varchar(255),
+
+ foreign key (user_id, device_id) references devices(user_id, id)
+ );
+SQL);