|
|
|
CREATE TABLE pbx_organizacao
|
|
|
|
(
|
|
|
|
id serial NOT NULL PRIMARY KEY,
|
|
|
|
nome VARCHAR(128) NOT NULL,
|
|
|
|
status INTEGER NOT NULL DEFAULT 1,
|
|
|
|
master int not null DEFAULT 0,
|
|
|
|
updated_at timestamp without time zone,
|
|
|
|
created_at timestamp without time zone NOT NULL DEFAULT now()
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE pbx_organizacao_usuarios
|
|
|
|
(
|
|
|
|
id SERIAL not null primary key,
|
|
|
|
id_usuario INTEGER not null,
|
|
|
|
id_organizacao INTEGER not null,
|
|
|
|
updated_at timestamp without time zone,
|
|
|
|
created_at timestamp without time zone NOT NULL DEFAULT now()
|
|
|
|
);
|
|
|
|
|
|
|
|
ALTER TABLE pbx_organizacao_usuarios ADD CONSTRAINT id_usuario FOREIGN KEY (id_usuario)
|
|
|
|
REFERENCES pbx_usuarios(id) ON DELETE CASCADE;
|
|
|
|
|
|
|
|
ALTER TABLE pbx_organizacao_usuarios ADD CONSTRAINT id_organizacao FOREIGN KEY (id_organizacao)
|
|
|
|
REFERENCES pbx_organizacao(id) ON DELETE CASCADE;
|
|
|
|
|
|
|
|
|
|
|
|
--create temporary table tpbx_facilidades as select * from pbx_facilidades where id = 1;
|
|
|
|
--alter table tpbx_facilidades drop column id;
|
|
|
|
--insert into pbx_facilidades select * from tpbx_facilidades;
|
|
|
|
-- update from pbx_facilidades set org_id = $org_id where id = $id
|
|
|
|
|
|
|
|
create temporary table tpbx_features_featuremap as select * from pbx_features_featuremap where id = 1;
|
|
|
|
alter table tpbx_features_featuremap drop column id;
|
|
|
|
insert into pbx_features_featuremap select * from tpbx_features_featuremap;
|
|
|
|
update pbx_features_featuremap set org_id = $org_id where id = $id
|
|
|
|
|
|
|
|
create temporary table tpbx_features_general as select * from pbx_features_general where id = 1;
|
|
|
|
alter table tpbx_features_general drop column id;
|
|
|
|
insert into pbx_features_general select * from tpbx_features_general;
|
|
|
|
update pbx_features_general set org_id = $org_id where id = $id
|
|
|
|
|
|
|
|
create temporary table tpbx_iax_general as select * from pbx_iax_general where id = 1;
|
|
|
|
alter table tpbx_iax_general drop column id;
|
|
|
|
insert into pbx_iax_general select * from tpbx_iax_general;
|
|
|
|
update pbx_iax_general set org_id = 2 where id = 4
|
|
|
|
|
|
|
|
-- pbx_parametros
|
|
|
|
|
|
|
|
------------------------------------------
|
|
|
|
----- ADICAO DE ID NAS TABELAS -----
|
|
|
|
------------------------------------------
|
|
|
|
ALTER TABLE pbx_sip_general ADD COLUMN id SERIAL PRIMARY KEY;
|
|
|
|
ALTER TABLE pbx_iax_general ADD COLUMN id SERIAL PRIMARY KEY;
|
|
|
|
ALTER TABLE pbx_facilidades ADD COLUMN id SERIAL PRIMARY KEY;
|
|
|
|
ALTER TABLE pbx_features_general ADD COLUMN id SERIAL PRIMARY KEY;
|
|
|
|
ALTER TABLE pbx_features_featuremap ADD COLUMN id SERIAL PRIMARY KEY;
|
|
|
|
ALTER TABLE pbx_voicemail_general ADD COLUMN id SERIAL PRIMARY KEY;
|
|
|
|
ALTER TABLE pbx_usuarios DROP CONSTRAINT pbx_usuarios_new_matricula_key;
|
|
|
|
DROP INDEX "pbx_usuarios_matricula_key";
|
|
|
|
DROP INDEX "idxUsuariosApelido";
|
|
|
|
ALTER TABLE pbx_grupo DROP CONSTRAINT "idxGrupNome";
|
|
|
|
DROP INDEX "idxGrupNome";
|
|
|
|
ALTER TABLE pbx_grupo_usuario DROP CONSTRAINT "pkGpUserId";
|
|
|
|
ALTER TABLE pbx_grupo ADD CONSTRAINT gp_id PRIMARY KEY (gp_id);
|
|
|
|
ALTER TABLE pbx_workflow_parametros DROP COLUMN wkf_id;
|
|
|
|
ALTER TABLE pbx_workflow_parametros ADD COLUMN wkf_id SERIAL PRIMARY KEY;
|
|
|
|
ALTER TABLE pbx_parametros DROP COLUMN id;
|
|
|
|
ALTER TABLE pbx_parametros ADD COLUMN id SERIAL PRIMARY KEY;
|