forked from taskcluster/taskcluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0019-downgrade.sql
41 lines (37 loc) · 1.49 KB
/
0019-downgrade.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
33
34
35
36
37
38
39
40
41
begin
-- lock this table before reading from it, to prevent loss of concurrent
-- updates when the table is dropped.
lock table queue_artifacts;
raise log 'TIMING start queue_artifacts_entities create table';
create table queue_artifacts_entities(
partition_key text, row_key text,
value jsonb not null,
version integer not null,
etag uuid default public.gen_random_uuid());
raise log 'TIMING start queue_artifacts_entities primary key';
alter table queue_artifacts_entities add primary key (partition_key, row_key);
raise log 'TIMING start queue_artifacts_entities insert into';
insert into queue_artifacts_entities
select
encode_composite_key(task_id, run_id::text) as partition_key,
encode_string_key(name) as row_key,
entity_buf_encode(
jsonb_build_object(
'PartitionKey', encode_composite_key(task_id, run_id::text),
'RowKey', encode_string_key(name),
'taskId', slugid_to_uuid(task_id),
'runId', run_id,
'name', name,
'storageType', storage_type,
'contentType', content_type,
'present', present,
'expires', expires),
'details', details::text) as value,
1 as version,
etag
from queue_artifacts;
raise log 'TIMING start queue_artifacts_entities permissions';
revoke select, insert, update, delete on queue_artifacts from $db_user_prefix$_queue;
drop table queue_artifacts;
grant select, insert, update, delete on queue_artifacts_entities to $db_user_prefix$_queue;
end