Subversion Repositories Integrator Subversion

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
464 blopes 1
/*========tur===================================================*/
2
/* DBMS name:     PostgreSQL 8                                  */
3
/* Criado em:     19/07/2024                                        */
4
/* Autor: Bruno Lopes Peixoto                                       */
5
/*==============================================================*/
6
 
7
SET search_path = sc_sec;
8
 
9
/*==============================================================*/
10
/* Table: sec_notafiscal_referenciada                           */
11
/*==============================================================*/
12
CREATE TABLE sec_notafiscal_referenciada (
13
   seq_nota_fiscal      INT8                 NOT NULL,
14
   seq_nota_fiscalref   INT8                 NOT NULL,
15
   CONSTRAINT pk_notafiscalreferenciada PRIMARY KEY (seq_nota_fiscal, seq_nota_fiscalref)
16
);
17
 
18
-- set table ownership
19
ALTER TABLE sec_notafiscal_referenciada owner TO sc_sec
20
;
21
/*==============================================================*/
22
/* Index: ix_notafiscalreferenciada                             */
23
/*==============================================================*/
24
CREATE UNIQUE INDEX ix_notafiscalreferenciada ON sec_notafiscal_referenciada (
25
seq_nota_fiscal,
26
seq_nota_fiscalref
27
);
28
 
29
/*==============================================================*/
30
/* Index: ix_notafiscalref_notafiscal                       */
31
/*==============================================================*/
32
CREATE  INDEX ix_notafiscalref_notafiscal ON sec_notafiscal_referenciada (
33
seq_nota_fiscal
34
);
35
 
36
/*==============================================================*/
37
/* Index: ix_notafiscalref_notafiscalref                       */
38
/*==============================================================*/
39
CREATE  INDEX ix_notafiscalref_notafiscalref ON sec_notafiscal_referenciada (
40
seq_nota_fiscalref
41
);
42
 
43
ALTER TABLE sec_notafiscal_referenciada
44
   ADD CONSTRAINT fk_notafiscalref_notafiscal FOREIGN KEY (seq_nota_fiscal)
45
      REFERENCES sec_nota_fiscal (seq_nota_fiscal)
46
      ON DELETE RESTRICT ON UPDATE RESTRICT;
47
 
48
ALTER TABLE sec_notafiscal_referenciada
49
   ADD CONSTRAINT fk_notafiscalref_notafiscalref FOREIGN KEY (seq_nota_fiscalref)
50
      REFERENCES sec_nota_fiscal (seq_nota_fiscal)
51
      ON DELETE RESTRICT ON UPDATE RESTRICT;
52
 
53
 
54
 
55
 
56
 
57
 
58
/*****************
59
 
60
ALTER TABLE sec_extrato_banco DROP CONSTRAINT ck_extratobanco_tipo;
61
ALTER TABLE sec_extrato_banco ADD CONSTRAINT ck_extratobanco_tipo check (tip_extrato_banco in ('D','C','T','E','P','O','X'));
62
 
63
comment on column sec_extrato_banco.tip_extrato_banco is
64
'Valores possíveis:
65
D - Débitos
66
C - Créditos
67
T - Transferências
68
E - Transferências entre contas
69
P - Pagamentos
70
O - Outros
71
X - Sem Categoria';
72
 
73
ALTER TABLE sec_contabancaria_transferencia ADD COLUMN ind_conciliado BOOLEAN NULL;
74
UPDATE sec_contabancaria_transferencia SET ind_conciliado = false;
75
UPDATE sec_contabancaria_transferencia SET ind_conciliado = true WHERE dth_operacao < '2023-07-01 00:00:00';
76
ALTER TABLE sec_contabancaria_transferencia ALTER COLUMN ind_conciliado SET NOT NULL;
77
 
78
 
79
create sequence sq_funcionarioevento
80
increment 1
81
minvalue 1
82
maxvalue 99999999
83
start 1;
84
 
85
alter table sq_funcionarioevento owner to espacoc
86
;
87
 
88
create table sec_funcionario_evento (
89
   seq_funcionarioevento INT8                 not null default nextval('sc_sec.sq_funcionarioevento'::regclass),
90
   seq_funcionario      INT8                 not null,
91
   seq_usuario_cadastro INT8                 not null,
92
   seq_usuario_auditor  INT8                 null,
93
   dat_inicial          DATE                 not null,
94
   dat_final            DATE                 not null,
95
   dsc_evento           VARCHAR(240)         null,
96
   tip_evento           CHAR(1)              not null
97
      constraint ck_tipevento check (tip_evento in ('F','T','O','A','H')),
98
   constraint pk_funcionarioevento primary key (seq_funcionarioevento)
99
);
100
 
101
create  index ix_funcionarioevento_funcionario on sec_funcionario_evento (
102
seq_funcionario
103
);
104
 
105
comment on column sec_funcionario_evento.tip_evento is
106
'Valores possíveis:
107
F - Falta
108
T - Troca de horário
109
O - Folga forçada
110
A - Atestado Médico
111
H - Hora Extra';
112
 
113
-- set table ownership
114
alter table sec_funcionario_evento owner to espacoc
115
;
116
 
117
create unique index ix_funcionarioevento on sec_funcionario_evento (
118
seq_funcionarioevento
119
);
120
 
121
alter table sec_funcionario_evento
122
   add constraint fk_funcionarioevento_funcionario foreign key (seq_funcionario)
123
      references sec_funcionario (seq_funcionario)
124
      on delete restrict on update restrict;
125
 
126
alter table sec_funcionario_evento
127
   add constraint fk_funcionarioevento_usuarioauditor foreign key (seq_usuario_auditor)
128
      references sec_usuario (seq_usuario)
129
      on delete restrict on update restrict;
130
 
131
alter table sec_funcionario_evento
132
   add constraint fk_funcionarioevento_usuariocadastro foreign key (seq_usuario_cadastro)
133
      references sec_usuario (seq_usuario)
134
      on delete restrict on update restrict;
135
 
136
 
137
**/
138
 
139
SET search_path = public;