Merge branch 'develop' into activation-meta
[akkoma] / priv / repo / migrations / 20200607112923_change_chat_id_to_flake.exs
1 defmodule Pleroma.Repo.Migrations.ChangeChatIdToFlake do
2 use Ecto.Migration
3
4 def up do
5 execute("""
6 alter table chats
7 drop constraint chats_pkey cascade,
8 alter column id drop default,
9 alter column id set data type uuid using cast( lpad( to_hex(id), 32, '0') as uuid),
10 add primary key (id)
11 """)
12
13 execute("""
14 alter table chat_message_references
15 alter column chat_id set data type uuid using cast( lpad( to_hex(chat_id), 32, '0') as uuid),
16 add constraint chat_message_references_chat_id_fkey foreign key (chat_id) references chats(id) on delete cascade
17 """)
18 end
19
20 def down do
21 :ok
22 end
23 end