From: Gustavo Martin Morcuende Date: Wed, 28 Dec 2016 16:58:55 +0000 (+0100) Subject: Flyway, configuration example and thoughts :( X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=6aa1a2436a7d988360b2da38add2f9e60678153a;p=JavaForFun Flyway, configuration example and thoughts :( --- diff --git a/SpringJava/Gradle/spring-jpa-persistence/src/main/resources/spring-configuration/datasource-configuration.xml b/SpringJava/Gradle/spring-jpa-persistence/src/main/resources/spring-configuration/datasource-configuration.xml index 6b5500c..116a95b 100644 --- a/SpringJava/Gradle/spring-jpa-persistence/src/main/resources/spring-configuration/datasource-configuration.xml +++ b/SpringJava/Gradle/spring-jpa-persistence/src/main/resources/spring-configuration/datasource-configuration.xml @@ -1,14 +1,11 @@ @@ -25,7 +22,13 @@ - + + - + + + + diff --git a/SpringJava/Gradle/spring-jpa-persistence/src/main/resources/spring-configuration/flyway/V1__Initial_Setup.sql b/SpringJava/Gradle/spring-jpa-persistence/src/main/resources/spring-configuration/flyway/V1__Initial_Setup.sql new file mode 100644 index 0000000..97d1948 --- /dev/null +++ b/SpringJava/Gradle/spring-jpa-persistence/src/main/resources/spring-configuration/flyway/V1__Initial_Setup.sql @@ -0,0 +1,177 @@ + + +CREATE TABLE AD ( + ID BIGINT AUTO_INCREMENT NOT NULL, + COMPANY_ID BIGINT, + COMPANY_CATEG_ID BIGINT, + AD_GPS BLOB, + AD_MOBILE_IMAGE VARCHAR(255), + CREATED_AT TIMESTAMP DEFAULT NOW() NOT NULL, + UPDATED_AT TIMESTAMP DEFAULT '1970-01-01 00:00:01' NOT NULL, + CONSTRAINT PK_AD PRIMARY KEY (ID) + ); + + +CREATE TABLE AD_AUDITED ( + ID BIGINT NOT NULL, + REVISION BIGINT NOT NULL, + REVISION_TYPE TINYINT(3), + REVISION_END BIGINT, + REVISION_END_TIMESTAMP TIMESTAMP, + AD_MOBILE_IMAGE VARCHAR(255), + adMobileImage_MODIFIED BOOLEAN(1), + COMPANY_CATEG_ID BIGINT, + companyCategId_MODIFIED BOOLEAN(1), + COMPANY_ID BIGINT, + companyId_MODIFIED BOOLEAN(1), + CREATED_AT TIMESTAMP, + createdAt_MODIFIED BOOLEAN(1), + UPDATED_AT TIMESTAMP, + updatedAt_MODIFIED BOOLEAN(1), + adDescriptions_MODIFIED BOOLEAN(1)); + + +CREATE TABLE AD_DESCRIPTION ( + ID BIGINT AUTO_INCREMENT NOT NULL, + LANGUAGE_ID BIGINT NOT NULL, + AD_ID BIGINT, + AD_NAME VARCHAR(255) NOT NULL, + AD_DESCRIPTION CLOB, + AD_MOBILE_TEXT VARCHAR(500) NOT NULL, + AD_LINK VARCHAR(3000) NOT NULL, + CONSTRAINT PK_AD_DESCRIPTION PRIMARY KEY (ID) + ); + + + +CREATE TABLE AD_DESCRIPTION_AUDITED ( + ID BIGINT NOT NULL, + REVISION BIGINT NOT NULL, + REVISION_TYPE TINYINT(3), + REVISION_END BIGINT, + REVISION_END_TIMESTAMP TIMESTAMP, + AD_DESCRIPTION VARCHAR(255), + AD_LINK VARCHAR(255), + AD_MOBILE_TEXT VARCHAR(255), + AD_NAME VARCHAR(255), + LANGUAGE_ID BIGINT, + AD_ID BIGINT + ); + + + +CREATE TABLE CUSTOM_REVISION ( + ID BIGINT AUTO_INCREMENT NOT NULL, + REVISION_DATE TIMESTAMP NOT NULL, + USERNAME VARCHAR(255), + CONSTRAINT PK_CUSTOM_REVISION PRIMARY KEY (ID) + ); + + + + + + + -- OTRO + + + +CREATE TABLE AD ( + ID bigint(20) NOT NULL AUTO_INCREMENT, + COMPANY_ID bigint(20) DEFAULT NULL, + COMPANY_CATEG_ID bigint(20) DEFAULT NULL, + AD_GPS blob, + AD_MOBILE_IMAGE varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + CREATED_AT timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + UPDATED_AT timestamp NOT NULL DEFAULT '1970-01-01 00:00:01', + PRIMARY KEY (ID) +); + + +CREATE TABLE AD_DESCRIPTION ( + ID bigint(20) NOT NULL AUTO_INCREMENT, + LANGUAGE_ID bigint(20) NOT NULL, + AD_ID bigint(20) DEFAULT NULL, + AD_NAME varchar(255) COLLATE utf8_unicode_ci NOT NULL, + AD_DESCRIPTION longtext COLLATE utf8_unicode_ci, + AD_MOBILE_TEXT varchar(500) COLLATE utf8_unicode_ci NOT NULL, + AD_LINK varchar(3000) COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (ID), + KEY IND_01_AD_DESCRIPTION (AD_ID), + CONSTRAINT FK_01_AD_DESCRIPTION FOREIGN KEY (AD_ID) REFERENCES AD (ID) ON DELETE NO ACTION ON UPDATE NO ACTION +); + + +CREATE TABLE CUSTOM_REVISION ( + ID bigint(20) NOT NULL AUTO_INCREMENT, + REVISION_DATE timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + USERNAME varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + PRIMARY KEY (ID) +); + + +CREATE TABLE AD_AUDITED ( + ID bigint(20) NOT NULL, + REVISION bigint(20) NOT NULL, + REVISION_TYPE tinyint(3) DEFAULT NULL, + REVISION_END bigint(20) DEFAULT NULL, + REVISION_END_TIMESTAMP datetime DEFAULT NULL, + AD_MOBILE_IMAGE varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + adMobileImage_MODIFIED bit(1) DEFAULT NULL, + COMPANY_CATEG_ID bigint(20) DEFAULT NULL, + companyCategId_MODIFIED bit(1) DEFAULT NULL, + COMPANY_ID bigint(20) DEFAULT NULL, + companyId_MODIFIED bit(1) DEFAULT NULL, + CREATED_AT datetime DEFAULT NULL, + createdAt_MODIFIED bit(1) DEFAULT NULL, + UPDATED_AT datetime DEFAULT NULL, + updatedAt_MODIFIED bit(1) DEFAULT NULL, + adDescriptions_MODIFIED bit(1) DEFAULT NULL, + PRIMARY KEY (ID,REVISION), + KEY IND_01_AD_AUDITED (REVISION), + KEY IND_02_AD_AUDITED (REVISION_END), + CONSTRAINT FK_01_AD_AUDITED FOREIGN KEY (REVISION) REFERENCES CUSTOM_REVISION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT FK_02_AD_AUDITED FOREIGN KEY (REVISION_END) REFERENCES CUSTOM_REVISION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION +); + +-- +-- CREATE TABLE "MYBATIS_EXAMPLE"."AD_AUDITED" ("ID" BIGINT NOT NULL, "REVISION" BIGINT NOT NULL, "REVISION_TYPE" TINYINT(3), "REVISION_END" BIGINT, "REVISION_END_TIMESTAMP" TIMESTAMP, "AD_MOBILE_IMAGE" VARCHAR(255), "adMobileImage_MODIFIED" BOOLEAN(1), "COMPANY_CATEG_ID" BIGINT, "companyCategId_MODIFIED" BOOLEAN(1), "COMPANY_ID" BIGINT, "companyId_MODIFIED" BOOLEAN(1), "CREATED_AT" TIMESTAMP, "createdAt_MODIFIED" BOOLEAN(1), "UPDATED_AT" TIMESTAMP, "updatedAt_MODIFIED" BOOLEAN(1), "adDescriptions_MODIFIED" BOOLEAN(1)) +-- + + + +CREATE TABLE AD_DESCRIPTION_AUDITED ( + ID bigint(20) NOT NULL, + REVISION bigint(20) NOT NULL, + REVISION_TYPE tinyint(3) DEFAULT NULL, + REVISION_END bigint(20) DEFAULT NULL, + REVISION_END_TIMESTAMP datetime DEFAULT NULL, + AD_DESCRIPTION varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + AD_LINK varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + AD_MOBILE_TEXT varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + AD_NAME varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, + LANGUAGE_ID bigint(20) DEFAULT NULL, + AD_ID bigint(20) DEFAULT NULL, + PRIMARY KEY (ID,REVISION), + KEY IND_01_AD_DESCRIPTION_AUDITED (REVISION), + KEY IND_02_AD_DESCRIPTION_AUDITED (REVISION_END), + CONSTRAINT FK_01_AD_DESCRIPTION_AUDITED FOREIGN KEY (REVISION) REFERENCES CUSTOM_REVISION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, + CONSTRAINT FK_02_AD_DESCRIPTION_AUDITED FOREIGN KEY (REVISION_END) REFERENCES CUSTOM_REVISION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION +); + + + + diff --git a/SpringJava/Gradle/spring-jpa-persistence/src/main/resources/spring-configuration/flyway/flyway.conf b/SpringJava/Gradle/spring-jpa-persistence/src/main/resources/spring-configuration/flyway/flyway.conf new file mode 100644 index 0000000..e69de29 diff --git a/SpringJava/Gradle/spring-jpa-persistence/src/main/resources/spring-configuration/flyway/flyway.xml b/SpringJava/Gradle/spring-jpa-persistence/src/main/resources/spring-configuration/flyway/flyway.xml new file mode 100644 index 0000000..676bd6d --- /dev/null +++ b/SpringJava/Gradle/spring-jpa-persistence/src/main/resources/spring-configuration/flyway/flyway.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + \ No newline at end of file