summaryrefslogtreecommitdiff
path: root/priv
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2020-06-07 14:25:30 +0200
committerlain <lain@soykaf.club>2020-06-07 14:25:30 +0200
commit1a11f0e453527070a8ab5511318045470abc95e2 (patch)
tree2eeea851de5cf8df7112f6d5ed99eac8412ad3a7 /priv
parent0365053c8dbbcae4a4883f68b7eaec263c14f656 (diff)
downloadpleroma-1a11f0e453527070a8ab5511318045470abc95e2.tar.gz
pleroma-1a11f0e453527070a8ab5511318045470abc95e2.zip
Chats: Change id to flake id.
Diffstat (limited to 'priv')
-rw-r--r--priv/repo/migrations/20200607112923_change_chat_id_to_flake.exs23
1 files changed, 23 insertions, 0 deletions
diff --git a/priv/repo/migrations/20200607112923_change_chat_id_to_flake.exs b/priv/repo/migrations/20200607112923_change_chat_id_to_flake.exs
new file mode 100644
index 000000000..f14e269ca
--- /dev/null
+++ b/priv/repo/migrations/20200607112923_change_chat_id_to_flake.exs
@@ -0,0 +1,23 @@
+defmodule Pleroma.Repo.Migrations.ChangeChatIdToFlake do
+ use Ecto.Migration
+
+ def up do
+ execute("""
+ alter table chats
+ drop constraint chats_pkey cascade,
+ alter column id drop default,
+ alter column id set data type uuid using cast( lpad( to_hex(id), 32, '0') as uuid),
+ add primary key (id)
+ """)
+
+ execute("""
+ alter table chat_message_references
+ alter column chat_id set data type uuid using cast( lpad( to_hex(chat_id), 32, '0') as uuid),
+ add constraint chat_message_references_chat_id_fkey foreign key (chat_id) references chats(id) on delete cascade
+ """)
+ end
+
+ def down do
+ :ok
+ end
+end