Skip to content

Commit

Permalink
Merge pull request #756 from portabilis/remove-oids
Browse files Browse the repository at this point in the history
[2.5] Prepara o i-Educar para upgrade do banco de dados
  • Loading branch information
edersoares authored Mar 17, 2021
2 parents 0937d4f + 3f061a2 commit 81087b5
Show file tree
Hide file tree
Showing 205 changed files with 551 additions and 927 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Software livre de gestão escolar",
"type": "project",
"license": "GPL-2.0-or-later",
"version": "2.5.3",
"version": "2.5.4",
"keywords": [
"Portabilis",
"i-Educar"
Expand Down
579 changes: 291 additions & 288 deletions composer.lock

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions database/migrations/2021_01_20_000000_remove_oids.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

class RemoveOids extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$tables = DB::select(
"select schemaname || '.' || tablename as table_name from pg_tables WHERE schemaname <> 'pg_catalog' AND schemaname <> 'information_schema';"
);

foreach ($tables as $table) {
DB::unprepared("alter table {$table->table_name} SET WITHOUT oids;");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public function up()
{
DB::unprepared(
'
SET default_with_oids = false;
CREATE SEQUENCE cadastro.codigo_cartorio_inep_id_seq
START WITH 1
INCREMENT BY 1
Expand All @@ -32,14 +30,14 @@ public function up()
cod_municipio integer,
ref_sigla_uf character varying(3)
);
ALTER SEQUENCE cadastro.codigo_cartorio_inep_id_seq OWNED BY cadastro.codigo_cartorio_inep.id;
ALTER TABLE ONLY cadastro.codigo_cartorio_inep
ADD CONSTRAINT pk_id PRIMARY KEY (id);
ALTER TABLE ONLY cadastro.codigo_cartorio_inep ALTER COLUMN id SET DEFAULT nextval(\'cadastro.codigo_cartorio_inep_id_seq\'::regclass);
SELECT pg_catalog.setval(\'cadastro.codigo_cartorio_inep_id_seq\', 14212, true);
'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public function up()
{
DB::unprepared(
'
SET default_with_oids = true;
CREATE SEQUENCE cadastro.deficiencia_cod_deficiencia_seq
START WITH 15
INCREMENT BY 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public function up()
{
DB::unprepared(
'
SET default_with_oids = true;
CREATE TABLE cadastro.documento (
idpes numeric(8,0) NOT NULL,
rg character varying(25),
Expand Down Expand Up @@ -53,7 +51,7 @@ public function up()
CONSTRAINT ck_documento_origem_gravacao CHECK (((origem_gravacao = \'M\'::bpchar) OR (origem_gravacao = \'U\'::bpchar) OR (origem_gravacao = \'C\'::bpchar) OR (origem_gravacao = \'O\'::bpchar))),
CONSTRAINT ck_documento_tipo_cert CHECK (((tipo_cert_civil >= (91)::numeric) AND (tipo_cert_civil <= (92)::numeric)))
);
ALTER TABLE ONLY cadastro.documento
ADD CONSTRAINT pk_documento PRIMARY KEY (idpes);
'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ public function up()
{
DB::unprepared(
'
SET default_with_oids = true;
CREATE TABLE cadastro.escolaridade (
idesco numeric(2,0) NOT NULL,
descricao character varying(60) NOT NULL,
escolaridade smallint
);
ALTER TABLE ONLY cadastro.escolaridade
ADD CONSTRAINT pk_escolaridade PRIMARY KEY (idesco);
'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ public function up()
{
DB::unprepared(
'
SET default_with_oids = true;
CREATE TABLE cadastro.estado_civil (
ideciv numeric(1,0) NOT NULL,
descricao character varying(15) NOT NULL
);
ALTER TABLE ONLY cadastro.estado_civil
ADD CONSTRAINT pk_estado_civil PRIMARY KEY (ideciv);
'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ public function up()
{
DB::unprepared(
'
SET default_with_oids = true;
CREATE TABLE cadastro.fisica_deficiencia (
ref_idpes integer NOT NULL,
ref_cod_deficiencia integer NOT NULL
);
ALTER TABLE ONLY cadastro.fisica_deficiencia
ADD CONSTRAINT pk_fisica_deficiencia PRIMARY KEY (ref_idpes, ref_cod_deficiencia);
'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ public function up()
{
DB::unprepared(
'
SET default_with_oids = true;
CREATE TABLE cadastro.fisica_foto (
idpes integer NOT NULL,
caminho character varying(255),
updated_at timestamp NULL DEFAULT now()
);
ALTER TABLE ONLY cadastro.fisica_foto
ADD CONSTRAINT fisica_foto_pkey PRIMARY KEY (idpes);
'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ public function up()
{
DB::unprepared(
'
SET default_with_oids = true;
CREATE TABLE cadastro.fisica_raca (
ref_idpes integer NOT NULL,
ref_cod_raca integer NOT NULL
);
ALTER TABLE ONLY cadastro.fisica_raca
ADD CONSTRAINT pk_fisica_raca PRIMARY KEY (ref_idpes);
'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public function up()
{
DB::unprepared(
'
SET default_with_oids = true;
CREATE TABLE cadastro.fisica (
idpes numeric(8,0) NOT NULL,
data_nasc date,
Expand Down Expand Up @@ -75,7 +73,7 @@ public function up()
CONSTRAINT ck_fisica_origem_gravacao CHECK (((origem_gravacao = \'M\'::bpchar) OR (origem_gravacao = \'U\'::bpchar) OR (origem_gravacao = \'C\'::bpchar) OR (origem_gravacao = \'O\'::bpchar))),
CONSTRAINT ck_fisica_sexo CHECK (((sexo = \'M\'::bpchar) OR (sexo = \'F\'::bpchar)))
);
ALTER TABLE ONLY cadastro.fisica
ADD CONSTRAINT pk_fisica PRIMARY KEY (idpes);
'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public function up()
{
DB::unprepared(
'
SET default_with_oids = true;
CREATE TABLE cadastro.fone_pessoa (
idpes numeric(8,0) NOT NULL,
tipo numeric(1,0) NOT NULL,
Expand All @@ -32,7 +30,7 @@ public function up()
CONSTRAINT ck_fone_pessoa_origem_gravacao CHECK (((origem_gravacao = \'M\'::bpchar) OR (origem_gravacao = \'U\'::bpchar) OR (origem_gravacao = \'C\'::bpchar) OR (origem_gravacao = \'O\'::bpchar))),
CONSTRAINT ck_fone_pessoa_tipo CHECK (((tipo >= (1)::numeric) AND (tipo <= (4)::numeric)))
);
ALTER TABLE ONLY cadastro.fone_pessoa
ADD CONSTRAINT pk_fone_pessoa PRIMARY KEY (idpes, tipo);
'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public function up()
{
DB::unprepared(
'
SET default_with_oids = true;
CREATE TABLE cadastro.juridica (
idpes numeric(8,0) NOT NULL,
cnpj numeric(14,0) NOT NULL,
Expand All @@ -32,10 +30,10 @@ public function up()
CONSTRAINT ck_juridica_operacao CHECK (((operacao = \'I\'::bpchar) OR (operacao = \'A\'::bpchar) OR (operacao = \'E\'::bpchar))),
CONSTRAINT ck_juridica_origem_gravacao CHECK (((origem_gravacao = \'M\'::bpchar) OR (origem_gravacao = \'U\'::bpchar) OR (origem_gravacao = \'C\'::bpchar) OR (origem_gravacao = \'O\'::bpchar)))
);
ALTER TABLE ONLY cadastro.juridica
ADD CONSTRAINT pk_juridica PRIMARY KEY (idpes);
CREATE UNIQUE INDEX un_juridica_cnpj ON cadastro.juridica USING btree (cnpj);
'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ public function up()
{
DB::unprepared(
'
SET default_with_oids = true;
CREATE TABLE cadastro.ocupacao (
idocup numeric(6,0) NOT NULL,
descricao character varying(250) NOT NULL
);
ALTER TABLE ONLY cadastro.ocupacao
ADD CONSTRAINT pk_ocupacao PRIMARY KEY (idocup);
'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public function up()
{
DB::unprepared(
'
SET default_with_oids = true;
CREATE SEQUENCE cadastro.orgao_emissor_rg_idorg_rg_seq
START WITH 30
INCREMENT BY 1
Expand All @@ -32,7 +30,7 @@ public function up()
codigo_educacenso integer,
CONSTRAINT ck_orgao_emissor_rg_situacao CHECK (((situacao = \'A\'::bpchar) OR (situacao = \'I\'::bpchar)))
);
ALTER TABLE ONLY cadastro.orgao_emissor_rg
ADD CONSTRAINT pk_orgao_emissor_rg PRIMARY KEY (idorg_rg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public function up()
{
DB::unprepared(
'
SET default_with_oids = true;
CREATE SEQUENCE cadastro.seq_pessoa
START WITH 0
INCREMENT BY 1
Expand All @@ -42,7 +40,7 @@ public function up()
CONSTRAINT ck_pessoa_situacao CHECK (((situacao = \'A\'::bpchar) OR (situacao = \'I\'::bpchar) OR (situacao = \'P\'::bpchar))),
CONSTRAINT ck_pessoa_tipo CHECK (((tipo = \'F\'::bpchar) OR (tipo = \'J\'::bpchar)))
);
ALTER TABLE ONLY cadastro.pessoa
ADD CONSTRAINT pk_pessoa PRIMARY KEY (idpes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public function up()
{
DB::unprepared(
'
SET default_with_oids = true;
CREATE SEQUENCE cadastro.raca_cod_raca_seq
START WITH 1
INCREMENT BY 1
Expand All @@ -34,7 +32,7 @@ public function up()
ativo boolean DEFAULT false,
raca_educacenso smallint
);
ALTER TABLE ONLY cadastro.raca
ADD CONSTRAINT raca_pkey PRIMARY KEY (cod_raca);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public function up()
{
DB::unprepared(
'
SET default_with_oids = false;
CREATE SEQUENCE cadastro.religiao_cod_religiao_seq
START WITH 1
INCREMENT BY 1
Expand All @@ -33,7 +31,7 @@ public function up()
data_exclusao timestamp without time zone,
ativo boolean DEFAULT false
);
ALTER TABLE ONLY cadastro.religiao
ADD CONSTRAINT religiao_pkey PRIMARY KEY (cod_religiao);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public function up()
{
DB::unprepared(
'
SET default_with_oids = false;
CREATE SEQUENCE modules.area_conhecimento_id_seq
START WITH 1
INCREMENT BY 1
Expand All @@ -32,14 +30,14 @@ public function up()
ordenamento_ac integer DEFAULT 99999,
updated_at timestamp NULL DEFAULT now()
);
ALTER SEQUENCE modules.area_conhecimento_id_seq OWNED BY modules.area_conhecimento.id;
ALTER TABLE ONLY modules.area_conhecimento
ADD CONSTRAINT area_conhecimento_pkey PRIMARY KEY (id, instituicao_id);
ALTER TABLE ONLY modules.area_conhecimento ALTER COLUMN id SET DEFAULT nextval(\'modules.area_conhecimento_id_seq\'::regclass);
CREATE INDEX area_conhecimento_nome_key ON modules.area_conhecimento USING btree (nome);
SELECT pg_catalog.setval(\'modules.area_conhecimento_id_seq\', 2, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public function up()
{
DB::unprepared(
'
SET default_with_oids = false;
CREATE TABLE modules.auditoria (
usuario character varying(300),
operacao smallint,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@ public function up()
{
DB::unprepared(
'
SET default_with_oids = false;
CREATE TABLE modules.calendario_turma (
calendario_ano_letivo_id integer NOT NULL,
ano integer NOT NULL,
mes integer NOT NULL,
dia integer NOT NULL,
turma_id integer NOT NULL
);
ALTER TABLE ONLY modules.calendario_turma
ADD CONSTRAINT calendario_turma_pk PRIMARY KEY (calendario_ano_letivo_id, ano, mes, dia, turma_id);
'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public function up()
{
DB::unprepared(
'
SET default_with_oids = false;
CREATE TABLE modules.componente_curricular_ano_escolar (
componente_curricular_id integer NOT NULL,
ano_escolar_id integer NOT NULL,
Expand Down
Loading

0 comments on commit 81087b5

Please sign in to comment.