Compare commits

...

3 Commits

Author SHA1 Message Date
william ea21e317f0 Add version 7 with group tokens 2022-04-25 22:05:59 -04:00
FyloZ e9aa9e30bb
Add version 6.2 with automatic migration, separating mix type and mix materials
continuous-integration/drone Build is passing Details
2022-04-15 14:00:26 -04:00
FyloZ af8b1538d8
Add version 6.1 with automatic migration of old material types format in mix type
continuous-integration/drone Build is passing Details
2022-04-11 22:57:29 -04:00
6 changed files with 118 additions and 3 deletions

View File

@ -1,11 +1,11 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
group = "dev.fyloz.colorrecipesexplorer" group = "dev.fyloz.colorrecipesexplorer"
version = "6.0" version = "6.2"
plugins { plugins {
kotlin("jvm") version "1.6.20" kotlin("jvm") version "1.6.20"
id("org.jetbrains.dokka") version "1.6.10" id("org.jetbrains.dokka") version "1.6.20"
id("maven-publish") id("maven-publish")
id("com.github.johnrengelman.shadow") version "7.1.2" id("com.github.johnrengelman.shadow") version "7.1.2"
} }

5
config.properties Normal file
View File

@ -0,0 +1,5 @@
database.target-version=7
database.url=jdbc:mysql://172.19.0.2/
database.name=cre
database.username=root
database.password=pass

View File

@ -5,7 +5,7 @@ import java.io.FileInputStream
import java.util.* import java.util.*
/** The latest version of the database supported by the utility. The [DatabaseUpdaterProperties] target version cannot be higher than this. */ /** The latest version of the database supported by the utility. The [DatabaseUpdaterProperties] target version cannot be higher than this. */
internal const val LATEST_DATABASE_VERSION = 6 internal const val LATEST_DATABASE_VERSION = 7
/** The key of the target version property */ /** The key of the target version property */
internal const val PROPERTY_TARGET_VERSION = "database.target-version" internal const val PROPERTY_TARGET_VERSION = "database.target-version"

View File

@ -27,6 +27,73 @@
</changeSet> </changeSet>
<changeSet id="4" author="william"> <changeSet id="4" author="william">
<sql>
UPDATE mix_type mt
LEFT JOIN material m
ON m.id = mt.material_id
LEFT JOIN material_type mmt ON mmt.id = m.material_type_id
SET mt.material_type_id = mmt.id
</sql>
</changeSet>
<changeSet id="5" author="william">
<dropNotNullConstraint tableName="mix_type" columnName="material_id" columnDataType="bigint"/> <dropNotNullConstraint tableName="mix_type" columnName="material_id" columnDataType="bigint"/>
<addNotNullConstraint tableName="mix_type" columnName="material_type_id" columnDataType="bigint"/>
</changeSet>
<changeSet id="6" author="william">
<createTable tableName="mix_mix_type">
<column name="id" type="bigint" autoIncrement="true">
<constraints nullable="false" primaryKey="true"/>
</column>
<column name="quantity" type="double">
<constraints nullable="false"/>
</column>
<column name="position" type="int" defaultOnNull="0">
<constraints nullable="false"/>
</column>
<column name="mix_type_id" type="bigint">
<constraints nullable="false"/>
</column>
<column name="mix_id" type="bigint">
<constraints nullable="false"/>
</column>
</createTable>
<createIndex tableName="mix_mix_type" indexName="ix_mix_mix_type_mix_type_id">
<column name="mix_type_id"/>
</createIndex>
<createIndex tableName="mix_mix_type" indexName="ix_mix_mix_type_mix_id">
<column name="mix_id"/>
</createIndex>
<addForeignKeyConstraint baseColumnNames="mix_type_id" baseTableName="mix_mix_type"
constraintName="fk_mix_mix_type_mix_type_mix_type_id"
referencedColumnNames="id" referencedTableName="mix_type"/>
<addForeignKeyConstraint baseColumnNames="mix_id" baseTableName="mix_mix_type"
constraintName="fk_mix_mix_type_mix_mix_id"
referencedColumnNames="id" referencedTableName="mix"/>
</changeSet>
<changeSet id="7" author="william">
<sql>
INSERT INTO mix_mix_type (mix_type_id, mix_id, quantity, position)
SELECT mm.mix_type_id, mm.mix_id, mm.quantity, mm.position
FROM (SELECT mt.id as mix_type_id, mm.mix_id, mm.quantity, mm.position
FROM mix_material mm
LEFT JOIN mix_type mt ON mt.material_id = mm.material_id) AS mm
WHERE mm.mix_type_id IS NOT NULL;
</sql>
</changeSet>
<changeSet id="8" author="william">
<update tableName="updater_metadata">
<column name="metadata_value" value="6"/>
<where>metadata_key='version'</where>
</update>
<rollback>
<update tableName="updater_metadata">
<column name="metadata_value" value="5"/>
<where>metadata_key='version'</where>
</update>
</rollback>
</changeSet> </changeSet>
</databaseChangeLog> </databaseChangeLog>

View File

@ -0,0 +1,29 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<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-3.9.xsd">
<changeSet id="1" author="william">
<createTable tableName="group_token">
<column name="id" type="binary(16)">
<constraints nullable="false" primaryKey="true"/>
</column>
<column name="name" type="varchar(255)">
<constraints nullable="false" unique="true"/>
</column>
<column name="is_valid" type="bit(1)" defaultValueBoolean="true">
<constraints nullable="false"/>
</column>
<column name="group_id" type="bigint">
<constraints nullable="false"/>
</column>
</createTable>
<createIndex tableName="default_group_token" indexName="ix_default_group_token_group_id">
<column name="group_id"/>
</createIndex>
<addForeignKeyConstraint baseColumnNames="group_id" baseTableName="default_group_token"
constraintName="fk_default_group_token_user_group_group_id"
referencedColumnNames="id" referencedTableName="user_group"/>
</changeSet>
</databaseChangeLog>

View File

@ -0,0 +1,14 @@
<?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-3.8.xsd">
<include file="/changelogs/changelog.1.xml"/>
<include file="/changelogs/changelog.2.xml"/>
<include file="/changelogs/changelog.3.xml"/>
<include file="/changelogs/changelog.4.xml"/>
<include file="/changelogs/changelog.5.xml"/>
<include file="/changelogs/changelog.6.xml"/>
<include file="/changelogs/changelog.7.xml"/>
</databaseChangeLog>