forked from SimplesIP/pabx-app
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
117 lines
3.4 KiB
117 lines
3.4 KiB
2 years ago
|
--drop table pbx_pesquisa
|
||
|
|
||
|
create table pbx_pesquisa
|
||
|
(
|
||
|
pp_id serial not null primary key,
|
||
|
pp_nome varchar(80) not null,
|
||
|
pp_data_inicio date,
|
||
|
pp_data_fim date,
|
||
|
pp_audio_saudacao varchar(255),
|
||
|
pp_audio_encerramento varchar(255),
|
||
|
pp_status int not null default 0,
|
||
|
pp_data date not null default now()::date,
|
||
|
user_reg varchar(20),
|
||
|
data_reg timestamp not null default now()
|
||
|
);
|
||
|
|
||
|
|
||
|
|
||
|
--select pp_id, pp_nome, pp_data_inicio, pp_data_fim, pp_audio_saudacao, pp_audio_encerramento, pp_status, pp_data from pbx_pesquisa where pp_status = 0
|
||
|
|
||
|
CREATE TABLE pbx_pesquisa_questoes
|
||
|
(
|
||
|
pp_id int NOT NULL,
|
||
|
pq_id serial not null,
|
||
|
pq_display int not null,
|
||
|
pq_questao character varying(2048) NOT NULL,
|
||
|
pq_tipo integer not null default 1,
|
||
|
pq_audio character varying(255),
|
||
|
pq_status integer NOT NULL DEFAULT 1,
|
||
|
user_reg character varying(20),
|
||
|
data_reg timestamp without time zone NOT NULL DEFAULT now(),
|
||
|
CONSTRAINT pk_pbx_pesquisa_questoes PRIMARY KEY (pp_id, pq_id)
|
||
|
)
|
||
|
|
||
|
select * from pbx_pesquisa_questoes
|
||
|
select * from pbx_pesquisa_questoes_pq_id_seq
|
||
|
|
||
|
CREATE TABLE pbx_pesquisa_opcoes
|
||
|
(
|
||
|
pp_id int NOT NULL,
|
||
|
pq_id int not null,
|
||
|
po_id serial not null,
|
||
|
po_display int not null default 0,
|
||
|
po_tecla int not null,
|
||
|
po_opcao character varying(1024) NOT NULL,
|
||
|
po_status integer NOT NULL DEFAULT 1,
|
||
|
user_reg character varying(20),
|
||
|
data_reg timestamp without time zone NOT NULL DEFAULT now(),
|
||
|
CONSTRAINT pk_pbx_pesquisa_opcoes PRIMARY KEY (pq_id, po_id)
|
||
|
);
|
||
|
|
||
|
select * from pbx_pesquisa_opcoes where pp_id = 71
|
||
|
|
||
|
|
||
|
create table pbx_pesquisa_questao_tipo
|
||
|
(
|
||
|
pqt_id int not null primary key,
|
||
|
pqt_descricao varchar(60) not null,
|
||
|
pqt_status int not null default 1,
|
||
|
user_reg character varying(20),
|
||
|
data_reg timestamp without time zone NOT NULL DEFAULT now()
|
||
|
);
|
||
|
|
||
|
--insert into pbx_pesquisa_questao_tipo values(1, 'Múltipla Escolha - seleção de uma alternativa');
|
||
|
--insert into pbx_pesquisa_questao_tipo values(2, 'Escalas de Classificação - Nota de até');
|
||
|
--select pqt_id, pqt_descricao from pbx_pesquisa_questao_tipo where pqt_status = 1
|
||
|
|
||
|
create table pbx_pesquisa_liberacao
|
||
|
(
|
||
|
pl_id serial not null primary key,
|
||
|
pp_id int not null,
|
||
|
pl_data date not null default now()::date,
|
||
|
pl_descricao varchar(80) not null,
|
||
|
pl_data_inicio date,
|
||
|
pl_data_fim date,
|
||
|
pl_ativa int not null default 1,
|
||
|
user_reg character varying(20),
|
||
|
data_reg timestamp without time zone NOT NULL DEFAULT now()
|
||
|
)
|
||
|
--select * from pbx_pesquisa_liberacao
|
||
|
|
||
|
create table pbx_pesquisa_liberacao_dacs
|
||
|
(
|
||
|
pl_id int not null,
|
||
|
id_dac int not null,
|
||
|
constraint "pkPesqisaLiberacaoDac" primary key(pl_id, id_dac)
|
||
|
)
|
||
|
|
||
|
select pl_id from pbx_pesquisa_liberacao where pp_id = 1
|
||
|
|
||
|
--select * from pbx_pesquisa_liberacao_dacs
|
||
|
|
||
|
create table pbx_pesquisa_movimento
|
||
|
(
|
||
|
pm_id serial not null primary key,
|
||
|
pl_id int not null,
|
||
|
pp_id int not null,
|
||
|
pq_id int not null,
|
||
|
po_id int not null,
|
||
|
uniqueid varchar(32) not null,
|
||
|
pm_data date,
|
||
|
user_reg character varying(20),
|
||
|
data_reg timestamp without time zone NOT NULL DEFAULT now()
|
||
|
)
|
||
|
|
||
|
CREATE UNIQUE INDEX "uniquePbxPesquisaMovimento"
|
||
|
ON pbx_pesquisa_movimento (pl_id ASC NULLS LAST, pp_id ASC NULLS LAST, pq_id ASC NULLS LAST, po_id ASC NULLS LAST, uniqueid ASC NULLS LAST);
|
||
|
|
||
|
|
||
|
select * from pbx_pesquisa;
|
||
|
select * from pbx_pesquisa_questoes;
|
||
|
select * from pbx_pesquisa_opcoes;
|
||
|
select * from pbx_pesquisa_liberacao;
|
||
|
select * from pbx_pesquisa_liberacao_dacs;
|
||
|
|
||
|
|