Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">
<!-- Criação das tabelas -->
<changeSet id="20180826-1" author="OsmarFilbido">
<comment>Criação da tabela MODELO_CHECK_LIST</comment>
<createTable tableName="MODELO_CHECK_LIST">
<column name="ID" type="BIGINT">
<constraints primaryKey="true" nullable="false" />
</column>
<column name="DESCRICAO" type="VARCHAR(50)">
<constraints nullable="false" />
</column>
<column name="TEXTO_LOCAL_AUDITADO" type="VARCHAR(50)">
<constraints nullable="false" />
</column>
<column name="FLAGEX" type="VARCHAR(1)" />
</createTable>
<rollback>
<dropTable tableName="MODELO_CHECK_LIST"/>
</rollback>
</changeSet>
<changeSet id="20180826-2" author="OsmarFilbido">
<comment>Criação da tabela M_ESTRUTURA_CL</comment>
<createTable tableName="M_ESTRUTURA_CL">
<column name="ID" type="BIGINT">
<constraints primaryKey="true" nullable="false" />
</column>
<column name="ID_MODELO_CHECK_LIST" type="BIGINT">
<constraints nullable="false"
foreignKeyName="FK_ID_MODELO_CHECK_LIST_E"
references="MODELO_CHECK_LIST(ID)" />
</column>
<column name="TIPO_ITEM" type="VARCHAR(50)">
<constraints nullable="false" />
</column>
<column name="DESCRICAO" type="VARCHAR(50)">
<constraints nullable="false" />
</column>
<column name="TIPO_CAMPO" type="VARCHAR(50)">
<constraints nullable="false" />
</column>
</createTable>
<rollback>
<dropTable tableName="M_ESTRUTURA_CL"/>
</rollback>
</changeSet>
<changeSet id="20180826-3" author="OsmarFilbido">
<comment>Criação da tabela M_ITEM_CL</comment>
<createTable tableName="M_ITEM_CL">
<column name="ID" type="BIGINT">
<constraints primaryKey="true" nullable="false" />
</column>
<column name="ID_MODELO_CHECK_LIST" type="BIGINT">
<constraints nullable="false"
foreignKeyName="FK_ID_MODELO_CHECK_LIST_I"
references="MODELO_CHECK_LIST(ID)" />
</column>
<column name="ID_CABECALHO" type="BIGINT" />
<column name="TIPO_ITEM" type="VARCHAR(50)">
<constraints nullable="false" />
</column>
<column name="NUMERO" type="VARCHAR(50)">
<constraints nullable="false" />
</column>
<column name="DESCRICAO" type="VARCHAR(100)">
<constraints nullable="false" />
</column>
</createTable>
<rollback>
<dropTable tableName="M_ITEM_CL"/>
</rollback>
</changeSet>
<changeSet id="20180826-4" author="OsmarFilbido">
<comment>Criação da sequence da tabela M_CAMPO_ITEM_CL</comment>
<createTable tableName="M_CAMPO_ITEM_CL">
<column name="ID" type="BIGINT">
<constraints primaryKey="true" nullable="true" />
</column>
<column name="ID_M_ITEM_CL" type="BIGINT">
<constraints nullable="true"
foreignKeyName="FK_ID_M_ITEM_CL" references="M_ITEM_CL(ID)" />
</column>
<column name="TIPO_ITEM" type="VARCHAR(50)">
<constraints nullable="false" />
</column>
<column name="DESCRICAO" type="VARCHAR(100)">
<constraints nullable="false" />
</column>
<column name="VALOR" type="VARCHAR(100)" />
<column name="TIPO_CAMPO" type="VARCHAR(100)">
<constraints nullable="false" />
</column>
</createTable>
<rollback>
<dropTable tableName="M_CAMPO_ITEM_CL"/>
</rollback>
</changeSet>
<!-- Criação das sequences -->
<changeSet id="20180826-5" author="OsmarFilbido">
<comment>Criação da sequence da tabela MODELO_CHECK_LIST</comment>
<createSequence cycle="false" incrementBy="1"
minValue="1" maxValue="999999999999999999999999999" ordered="false"
sequenceName="SEQ_MODELO_CHECK_LIST" startValue="1" />
<rollback>
<dropSequence sequenceName="SEQ_MODELO_CHECK_LIST"/>
</rollback>
</changeSet>
<changeSet id="20180826-6" author="OsmarFilbido">
<comment>Criação da sequence da tabela M_ESTRUTURA_CL</comment>
<createSequence cycle="false" incrementBy="1"
minValue="1" maxValue="999999999999999999999999999" ordered="false"
sequenceName="SEQ_M_ESTRUTURA_CL" startValue="1" />
<rollback>
<dropSequence sequenceName="SEQ_M_ESTRUTURA_CL"/>
</rollback>
</changeSet>
<changeSet id="20180826-7" author="OsmarFilbido">
<comment>Criação da sequence da tabela M_ITEM_CL</comment>
<createSequence cycle="false" incrementBy="1"
minValue="1" maxValue="999999999999999999999999999" ordered="false"
sequenceName="SEQ_M_ITEM_CL" startValue="1" />
<rollback>
<dropSequence sequenceName="SEQ_M_ITEM_CL"/>
</rollback>
</changeSet>
<changeSet id="20180826-8" author="OsmarFilbido">
<comment>Criação da sequence da tabela M_CAMPO_ITEM_CL</comment>
<createSequence cycle="false" incrementBy="1"
minValue="1" maxValue="999999999999999999999999999" ordered="false"
sequenceName="SEQ_M_CAMPO_ITEM_CL" startValue="1" />
<rollback>
<dropSequence sequenceName="SEQ_M_CAMPO_ITEM_CL"/>
</rollback>
</changeSet>
<!-- Criação das triggers -->
<changeSet id="20180826-9" author="OsmarFilbido">
<comment>Criação da trigger da tabela MODELO_CHECK_LIST</comment>
<sql endDelimiter="/">
CREATE OR REPLACE TRIGGER MODELO_CHECK_LIST_INCREMENT
BEFORE INSERT ON MODELO_CHECK_LIST
FOR EACH ROW
BEGIN
IF :new.id IS NULL THEN
SELECT SEQ_MODELO_CHECK_LIST.nextval INTO :new.id FROM dual;
END IF;
END;/
</sql>
<sql>
ALTER TRIGGER MODELO_CHECK_LIST_INCREMENT ENABLE;
</sql>
<rollback>
<sql>
DROP TRIGGER MODELO_CHECK_LIST_INCREMENT;
</sql>
</rollback>
</changeSet>
<changeSet id="20180826-10" author="OsmarFilbido">
<comment>Criação da trigger da tabela M_ESTRUTURA_CL</comment>
<sql endDelimiter="/">
CREATE OR REPLACE TRIGGER M_ESTRUTURA_CL_INCREMENT
BEFORE INSERT ON M_ESTRUTURA_CL
FOR EACH ROW
BEGIN
IF :NEW.ID IS NULL THEN
SELECT SEQ_M_ESTRUTURA_CL.NEXTVAL INTO :NEW.ID FROM DUAL;
END IF;
END;/
</sql>
<sql>
ALTER TRIGGER M_ESTRUTURA_CL_INCREMENT ENABLE;
</sql>
<rollback>
<sql>
DROP TRIGGER M_ESTRUTURA_CL_INCREMENT;
</sql>
</rollback>
</changeSet>
<changeSet id="20180826-11" author="OsmarFilbido">
<comment>Criação da trigger da tabela M_ITEM_CL</comment>
<sql endDelimiter="/">
CREATE OR REPLACE TRIGGER M_ITEM_CL_INCREMENT
BEFORE INSERT ON M_ITEM_CL
FOR EACH ROW
BEGIN
IF :NEW.ID IS NULL THEN
SELECT SEQ_M_ITEM_CL.NEXTVAL INTO :NEW.ID FROM DUAL;
END IF;
END;/
</sql>
<sql>
ALTER TRIGGER M_ITEM_CL_INCREMENT ENABLE;
</sql>
<rollback>
<sql>
DROP TRIGGER M_ITEM_CL_INCREMENT;
</sql>
</rollback>
</changeSet>
<changeSet id="20180826-12" author="OsmarFilbido">
<comment>Criação da trigger da tabela M_CAMPO_ITEM_CL</comment>
<sql endDelimiter="/">
CREATE OR REPLACE TRIGGER M_CAMPO_ITEM_CL_INCREMENT
BEFORE INSERT ON M_CAMPO_ITEM_CL
FOR EACH ROW
BEGIN
IF :NEW.ID IS NULL THEN
SELECT SEQ_M_CAMPO_ITEM_CL.NEXTVAL INTO :NEW.ID FROM DUAL;
END IF;
END;/
</sql>
<sql>
ALTER TRIGGER M_CAMPO_ITEM_CL_INCREMENT ENABLE;
</sql>
<rollback>
<sql>
DROP TRIGGER M_CAMPO_ITEM_CL_INCREMENT;
</sql>
</rollback>
</changeSet>
</databaseChangeLog>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment