Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- begin;
- alter table contrato_checklist drop column obs;
- alter table contrato_checklist drop column contrato_id;
- alter table contrato_checklist add column contrato_versao_id integer not null references contrato_versao (id);
- CREATE INDEX contrato_checklist_contrato_versao_id_idx on contrato_checklist(contrato_versao_id);
- create table contrato_checklist_versao (
- id serial primary key,
- contrato_checklist integer not null references contrato_checklist (id),
- corrente boolean not null default true,
- last_perfil integer not null references users_user_perfil (id),
- created timestamp without time zone not null default now(),
- modified timestamp without time zone not null default now()
- );
- CREATE INDEX contrato_checklist_versao_contrato_checklist_idx on contrato_checklist_versao(contrato_checklist);
- CREATE INDEX contrato_checklist_versao_last_perfil_idx on contrato_checklist_versao(last_perfil);
- alter table contrato_checklist_item_valor drop column checklist;
- alter table contrato_checklist_item_valor add column checklist_versao integer not null references contrato_checklist_versao (id);
- CREATE INDEX contrato_checklist_item_valor_checklist_versao_idx on contrato_checklist_item_valor(checklist_versao);
- CREATE TABLE contrato_checklist_adc (
- id serial primary key,
- contrato_versao_id integer not null references contrato_versao (id),
- checklist integer not null references checklist_versao (id),
- last_perfil integer not null references users_user_perfil (id),
- created timestamp without time zone not null default now(),
- modified timestamp without time zone not null default now()
- );
- CREATE INDEX contrato_checklist_adc_contrato_versao_id_idx on contrato_checklist_adc(contrato_versao_id);
- CREATE INDEX contrato_checklist_adc_checklist_idx on contrato_checklist_adc(checklist);
- CREATE INDEX contrato_checklist_adc_last_perfil_idx on contrato_checklist_adc(last_perfil);
- create table contrato_checklist_adc_versao (
- id serial primary key,
- contrato_checklist integer not null references contrato_checklist_adc (id),
- corrente boolean not null default true,
- last_perfil integer not null references users_user_perfil (id),
- created timestamp without time zone not null default now(),
- modified timestamp without time zone not null default now()
- );
- CREATE INDEX contrato_checklist_adc_versao_contrato_checklist_idx on contrato_checklist_adc_versao(contrato_checklist);
- CREATE INDEX contrato_checklist_adc_versao_last_perfil_idx on contrato_checklist_adc_versao(last_perfil);
- create table contrato_checklist_adc_estado (
- id serial primary key,
- checklist integer not null references contrato_checklist_adc (id),
- estado text not null references checklist_estado_estado (id),
- corrente boolean not null default true,
- last_perfil integer not null references users_user_perfil (id),
- created timestamp without time zone not null default now(),
- modified timestamp without time zone not null default now()
- );
- CREATE INDEX contrato_checklist_adc_estado_checklist_idx on contrato_checklist_adc_estado(checklist);
- CREATE INDEX contrato_checklist_adc_estado_estado_idx on contrato_checklist_adc_estado(estado);
- CREATE INDEX contrato_checklist_adc_estado_last_perfil_idx on contrato_checklist_adc_estado(last_perfil);
- create table contrato_checklist_adc_item_valor (
- id serial primary key,
- checklist_versao integer not null references contrato_checklist_adc_versao (id),
- item integer not null references checklist_item (id),
- valor integer references checklist_item_tipo_valores(id),
- obs text,
- created timestamp without time zone not null default now(),
- modified timestamp without time zone not null default now()
- );
- CREATE INDEX contrato_checklist_adc_item_valor_checklist_versao_idx on contrato_checklist_adc_item_valor(checklist_versao);
- CREATE INDEX contrato_checklist_adc_item_valor_item_idx on contrato_checklist_adc_item_valor(item);
- CREATE INDEX contrato_checklist_adc_item_valor_valor_idx on contrato_checklist_adc_item_valor(valor);
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement