-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker_postgres_init.sql
More file actions
47 lines (44 loc) · 1.41 KB
/
docker_postgres_init.sql
File metadata and controls
47 lines (44 loc) · 1.41 KB
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
42
43
44
45
46
CREATE TABLE IF NOT EXISTS sesion(
id serial primary key,
sesion_number int8 UNIQUE
);
CREATE TABLE IF NOT EXISTS legislatura(
id serial primary key,
nombre text not null unique,
inicio date not null,
fin date,
constraint legislatura_pkey primary key(id)
);
CREATE TABLE IF NOT EXISTS votacion (
id bigserial NOT NULL,
sesion_id int8 NOT NULL,
votacion_number int4 NOT NULL,
fecha date NOT NULL,
titulo text NOT NULL,
textoexpediente text NOT NULL,
titulosubgrupo text NOT NULL,
textosubgrupo text NOT NULL,
CONSTRAINT votacion_pkey PRIMARY KEY (id)
);
ALTER TABLE votacion ADD CONSTRAINT fk_sesion FOREIGN KEY(sesion_id) references sesion(sesion_number);
CREATE TABLE IF NOT EXISTS votos_resumido(
id bigserial NOT NULL,
votacion_id int8 NOT NULL,
grupo text NOT NULL,
a_favor text NOT NULL,
en_contra text NOT NULL,
abstencion text NOT NULL,
nsnc text NOT NULL,
CONSTRAINT votos_resumido_pkey PRIMARY KEY (id)
);
ALTER TABLE public.votos_resumido ADD CONSTRAINT fk_votacion_resumida FOREIGN KEY (votacion_id) REFERENCES public.votacion(id);
CREATE TABLE IF NOT EXISTS votos_detallado(
id bigserial NOT NULL,
votacion_id int8 NOT NULL,
asiento int4 NULL,
diputado text NOT NULL,
grupo text NOT NULL,
voto text NOT NULL,
CONSTRAINT votos_detallado_pkey PRIMARY KEY (id)
);
ALTER TABLE votos_detallado ADD CONSTRAINT fk_votacion FOREIGN KEY (votacion_id) REFERENCES public.votacion(id);