forked from taskcluster/taskcluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
0021-migration.sql
32 lines (28 loc) · 1.31 KB
/
0021-migration.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
begin
-- lock this table before reading from it, to prevent loss of concurrent
-- updates when the table is dropped. Note that this may lead to concurrent
-- updates failing; the important thing is that they not succeed without
-- taking effect. Failed updates will be retried.
lock table queue_task_groups_entities;
raise log 'TIMING start task_groups create table .. as select';
create table task_groups
as
select
uuid_to_slugid(value ->> 'taskGroupId')::text as task_group_id,
(value ->> 'schedulerId')::text as scheduler_id,
(value ->> 'expires')::timestamptz as expires,
queue_task_groups_entities.etag as etag
from queue_task_groups_entities;
raise log 'TIMING start task_groups add primary key';
alter table task_groups add primary key (task_group_id);
raise log 'TIMING start task_groups set not null';
alter table task_groups
alter column task_group_id set not null,
alter column scheduler_id set not null,
alter column expires set not null,
alter column etag set not null;
raise log 'TIMING start task_groups set permissions';
revoke select, insert, update, delete on queue_task_groups_entities from $db_user_prefix$_queue;
drop table queue_task_groups_entities;
grant select, insert, update, delete on task_groups to $db_user_prefix$_queue;
end