Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.12 KB | None | 0 0
  1. begin;
  2.  
  3. alter table contrato_checklist drop column obs;
  4. alter table contrato_checklist drop column contrato_id;
  5. alter table contrato_checklist add column contrato_versao_id integer not null references contrato_versao (id);
  6. CREATE INDEX contrato_checklist_contrato_versao_id_idx on contrato_checklist(contrato_versao_id);
  7.  
  8. create table contrato_checklist_versao (
  9. id serial primary key,
  10. contrato_checklist integer not null references contrato_checklist (id),
  11. corrente boolean not null default true,
  12. last_perfil integer not null references users_user_perfil (id),
  13. created timestamp without time zone not null default now(),
  14. modified timestamp without time zone not null default now()
  15. );
  16.  
  17. CREATE INDEX contrato_checklist_versao_contrato_checklist_idx on contrato_checklist_versao(contrato_checklist);
  18. CREATE INDEX contrato_checklist_versao_last_perfil_idx on contrato_checklist_versao(last_perfil);
  19.  
  20. alter table contrato_checklist_item_valor drop column checklist;
  21. alter table contrato_checklist_item_valor add column checklist_versao integer not null references contrato_checklist_versao (id);
  22. CREATE INDEX contrato_checklist_item_valor_checklist_versao_idx on contrato_checklist_item_valor(checklist_versao);
  23.  
  24.  
  25.  
  26. CREATE TABLE contrato_checklist_adc (
  27. id serial primary key,
  28. contrato_versao_id integer not null references contrato_versao (id),
  29. checklist integer not null references checklist_versao (id),
  30. last_perfil integer not null references users_user_perfil (id),
  31. created timestamp without time zone not null default now(),
  32. modified timestamp without time zone not null default now()
  33. );
  34.  
  35. CREATE INDEX contrato_checklist_adc_contrato_versao_id_idx on contrato_checklist_adc(contrato_versao_id);
  36. CREATE INDEX contrato_checklist_adc_checklist_idx on contrato_checklist_adc(checklist);
  37. CREATE INDEX contrato_checklist_adc_last_perfil_idx on contrato_checklist_adc(last_perfil);
  38.  
  39. create table contrato_checklist_adc_versao (
  40. id serial primary key,
  41. contrato_checklist integer not null references contrato_checklist_adc (id),
  42. corrente boolean not null default true,
  43. last_perfil integer not null references users_user_perfil (id),
  44. created timestamp without time zone not null default now(),
  45. modified timestamp without time zone not null default now()
  46. );
  47.  
  48. CREATE INDEX contrato_checklist_adc_versao_contrato_checklist_idx on contrato_checklist_adc_versao(contrato_checklist);
  49. CREATE INDEX contrato_checklist_adc_versao_last_perfil_idx on contrato_checklist_adc_versao(last_perfil);
  50.  
  51. create table contrato_checklist_adc_estado (
  52. id serial primary key,
  53. checklist integer not null references contrato_checklist_adc (id),
  54. estado text not null references checklist_estado_estado (id),
  55. corrente boolean not null default true,
  56. last_perfil integer not null references users_user_perfil (id),
  57. created timestamp without time zone not null default now(),
  58. modified timestamp without time zone not null default now()
  59. );
  60.  
  61. CREATE INDEX contrato_checklist_adc_estado_checklist_idx on contrato_checklist_adc_estado(checklist);
  62. CREATE INDEX contrato_checklist_adc_estado_estado_idx on contrato_checklist_adc_estado(estado);
  63. CREATE INDEX contrato_checklist_adc_estado_last_perfil_idx on contrato_checklist_adc_estado(last_perfil);
  64.  
  65.  
  66. create table contrato_checklist_adc_item_valor (
  67. id serial primary key,
  68. checklist_versao integer not null references contrato_checklist_adc_versao (id),
  69. item integer not null references checklist_item (id),
  70. valor integer references checklist_item_tipo_valores(id),
  71. obs text,
  72. created timestamp without time zone not null default now(),
  73. modified timestamp without time zone not null default now()
  74. );
  75.  
  76. CREATE INDEX contrato_checklist_adc_item_valor_checklist_versao_idx on contrato_checklist_adc_item_valor(checklist_versao);
  77. CREATE INDEX contrato_checklist_adc_item_valor_item_idx on contrato_checklist_adc_item_valor(item);
  78. CREATE INDEX contrato_checklist_adc_item_valor_valor_idx on contrato_checklist_adc_item_valor(valor);
  79.  
  80. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement