...
Code Block | ||
---|---|---|
| ||
alter table field add if not exists create_index bool; update field set create_index = false; alter table field alter column create_index set not null; alter table entity_structure add if not exists create_index bool; update entity_structure set create_index = true; alter table entity_structure alter column create_index set not null; do $$ declare r record; begin for r in select id FROM project where archive_initialized = true loop execute 'create table if not exists ' || r.id || '.content_access_group ( _amid uuid default uuid_generate_v4() not null unique, created timestamp, created_by varchar, updated timestamp, updated_by varchar, security_model_name varchar, id uuid default uuid_generate_v1mc() not null primary key, name varchar(36) not null unique, description varchar )'; execute 'alter table ' || r.id || '.content_access_group owner to "archive-manager"'; execute 'create table if not exists ' || r.id || '.content_screening ( _amid uuid default uuid_generate_v4() not null unique, created timestamp, created_by varchar, updated timestamp, updated_by varchar, id uuid default uuid_generate_v1mc() not null primary key, cag_id uuid not null constraint fk_ccb0a488_a9a9_4162_a149_494ab3ce7dd9 references ' || r.id || '.content_access_group deferrable initially deferred, object_id uuid not null, table_name_reference varchar not null, scope varchar not null, level integer not null, parent_screening_id uuid constraint fk_9a653aaa_aa8c_4bf9_a69a_9452f876aa75 references ' || r.id || '.content_screening deferrable initially deferred, field_names varchar(2000) )'; execute 'alter table ' || r.id || '.content_screening owner to "archive-manager"'; execute 'create index if not exists index_b49d524e_8148_43aa_9615_b653e50bb633 on ' || r.id || '.content_screening (object_id)'; end loop; end; $$ |
...