Ajout de la version 4 de la base de donnée:

* Information des recettes spécifique aux groupes
* Position dans les étapes des recettes
* Position dans les ingrédient d'un mélange
This commit is contained in:
FyloZ 2021-03-23 17:48:48 -04:00
parent 9a4042a6d0
commit fa83d3d283
4 changed files with 92 additions and 2 deletions

View File

@ -1,7 +1,7 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
group = "dev.fyloz.colorrecipesexplorer"
version = "1.1.1"
version = "1.2.0"
plugins {
kotlin("jvm") version "1.4.30"

View File

@ -5,7 +5,7 @@ import java.io.FileInputStream
import java.util.*
/** 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 = 3
internal const val LATEST_DATABASE_VERSION = 4
/** The key of the target version property */
internal const val PROPERTY_TARGET_VERSION = "database.target-version"

View File

@ -0,0 +1,79 @@
<?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="recipe_group_information">
<column name="id" type="BIGINT" autoIncrement="true">
<constraints nullable="false" primaryKey="true"/>
</column>
<column name="group_id" type="BIGINT">
<constraints nullable="false"/>
</column>
<column name="note" type="VARCHAR(255)"/>
<column name="recipe_id" type="BIGINT"/>
</createTable>
<addForeignKeyConstraint baseTableName="recipe_group_information" baseColumnNames="group_id"
constraintName="fk_recipe_group_information_employee_group_group_id"
referencedTableName="employee_group"
referencedColumnNames="id"/>
<addForeignKeyConstraint baseTableName="recipe_group_information" baseColumnNames="recipe_id"
constraintName="fk_recipe_group_information_recipe_recipe_id"
referencedTableName="recipe"
referencedColumnNames="id"/>
</changeSet>
<changeSet id="2" author="william">
<addColumn tableName="recipe_step">
<column name="position" type="INT" defaultValueNumeric="0">
<constraints nullable="false"/>
</column>
</addColumn>
<addColumn tableName="recipe_step">
<column name="recipe_group_information_id" type="BIGINT"/>
</addColumn>
<addForeignKeyConstraint baseTableName="recipe_step" baseColumnNames="recipe_group_information_id"
constraintName="fk_recipe_step_rgi_rgi_id"
referencedTableName="recipe_group_information"
referencedColumnNames="id"/>
</changeSet>
<changeSet id="3" author="william">
<sql>
INSERT INTO recipe_group_information (group_id, note, recipe_id)
SELECT g.id, r.note, r.id
FROM
(SELECT id, note FROM recipe) as r,
(SELECT id FROM employee_group ORDER BY id LIMIT 1) as g
</sql>
<sql>
UPDATE recipe_step s
INNER JOIN recipe_group_information rgi ON rgi.recipe_id=s.recipe_id
SET recipe_group_information_id=rgi.id
</sql>
</changeSet>
<changeSet id="4" author="william">
<dropColumn tableName="recipe" columnName="note"/>
<dropForeignKeyConstraint baseTableName="recipe_step" constraintName="fk_recipe_step_recipe_recipe_id"/>
<dropColumn tableName="recipe_step" columnName="recipe_id"/>
</changeSet>
<changeSet id="5" author="william">
<addColumn tableName="mix_material">
<column name="position" type="INT" defaultValueNumeric="0">
<constraints nullable="false"/>
</column>
</addColumn>
<dropNotNullConstraint tableName="mix_material" columnName="mix_id" columnDataType="BIGINT"/>
</changeSet>
<changeSet id="6" author="william">
<update tableName="updater_metadata">
<column name="metadata_value" value="4"/>
<where>metadata_key='version'</where>
</update>
<rollback>
<update tableName="updater_metadata">
<column name="metadata_value" value="3"/>
<where>metadata_key='version'</where>
</update>
</rollback>
</changeSet>
</databaseChangeLog>

View File

@ -0,0 +1,11 @@
<?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"/>
</databaseChangeLog>