summaryrefslogtreecommitdiff
path: root/migrations
diff options
context:
space:
mode:
Diffstat (limited to 'migrations')
-rw-r--r--migrations/20250819.php60
1 files changed, 58 insertions, 2 deletions
diff --git a/migrations/20250819.php b/migrations/20250819.php
index b635201..6e3c59b 100644
--- a/migrations/20250819.php
+++ b/migrations/20250819.php
@@ -20,6 +20,29 @@ Database::getInstance()->query(<<<SQL
SQL);
Database::getInstance()->query(<<<SQL
+ create table if not exists "account_data" (
+ "key" text not null,
+ "value" jsonb not null,
+
+ "user_id" text references users(id) not null,
+
+ primary key (user_id, key)
+ );
+SQL);
+
+Database::getInstance()->query(<<<SQL
+ create table if not exists "room_account_data" (
+ "key" text not null,
+ "value" jsonb not null,
+
+ "user_id" text references users(id) not null,
+ "room_id" text references rooms(id) not null,
+
+ primary key (user_id, room_id, key)
+ );
+SQL);
+
+Database::getInstance()->query(<<<SQL
create table if not exists "devices" (
"id" varchar(255) not null,
"name" varchar(255) not null,
@@ -54,7 +77,7 @@ Database::getInstance()->query(<<<SQL
"name" varchar(255) not null,
- "version" integer not null
+ "version" text not null
);
SQL);
@@ -96,7 +119,7 @@ SQL);
Database::getInstance()->query(<<<SQL
create table if not exists "filters" (
- "id" varchar(255) primary key,
+ "id" varchar(255) not null,
"account_data" jsonb,
"event_fields" jsonb,
"event_format" varchar(255),
@@ -105,6 +128,39 @@ Database::getInstance()->query(<<<SQL
"user_id" varchar(255) not null,
+ primary key (id, user_id),
foreign key (user_id) references users(id)
);
SQL);
+
+Database::getInstance()->query(<<<SQL
+ create table if not exists "device_keys" (
+ "supported_algorithms" json not null,
+ "keys" json not null,
+ "signatures" json not null,
+
+ "user_id" text not null,
+ "device_id" text not null,
+
+ foreign key (user_id, device_id) references devices(user_id, id)
+ );
+SQL);
+
+Database::getInstance()->query(<<<SQL
+ create table if not exists "one_time_keys" (
+ "id" text not null,
+
+ "key" text not null,
+ "algorithm" text not null,
+
+ "signature_key" text not null,
+ "signature_algorithm" text not null,
+
+ "is_fallback" bool not null default false,
+
+ "user_id" text not null,
+ "device_id" text not null,
+
+ foreign key (user_id, device_id) references devices(user_id, id)
+ );
+SQL);