1
0
mirror of synced 2024-11-24 20:56:04 +03:00
mg-transport-telegram/migrations/1527515265_app.up.sql

28 lines
779 B
MySQL
Raw Normal View History

2018-05-29 10:08:38 +03:00
alter table connection
add constraint connection_key unique (client_id, mg_token),
2018-05-29 10:08:38 +03:00
alter column client_id set not null,
alter column api_key set not null,
alter column api_url set not null,
alter column mg_url set not null,
alter column mg_token set not null,
alter column api_url type varchar(255),
alter column mg_url type varchar(255);
2018-05-29 10:08:38 +03:00
alter table bot
add column connection_id integer;
update bot b
set connection_id = c.id
from connection c
where b.client_id = c.client_id;
2018-05-29 10:08:38 +03:00
alter table bot
drop column client_id,
alter column channel set not null,
alter column token set not null,
add constraint bot_key unique (channel, token);
alter table bot add foreign key (connection_id) references connection on delete cascade;
2018-05-29 10:08:38 +03:00
drop table mapping;