170 lines
11 KiB
Java
170 lines
11 KiB
Java
package org.kar.karusic.migration;
|
|
|
|
import org.kar.archidata.migration.MigrationSqlStep;
|
|
|
|
public class Migration20231126 extends MigrationSqlStep {
|
|
|
|
public static final int KARSO_INITIALISATION_ID = 1;
|
|
|
|
@Override
|
|
public String getName() {
|
|
return "migration-2023-11-26: reorder the migration for the new API of archidata";
|
|
}
|
|
|
|
public Migration20231126() {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void generateStep() throws Exception {
|
|
// update migration update (last one)
|
|
addAction("""
|
|
ALTER TABLE `KAR_migration`
|
|
CHANGE `id` `id` bigint NOT NULL COMMENT 'Primary key of the base' AUTO_INCREMENT FIRST,
|
|
CHANGE `create_date` `createdAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'Create time of the object' AFTER `id`,
|
|
CHANGE `modify_date` `updatedAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'When update the object' AFTER `createdAt`,
|
|
CHANGE `deleted` `deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'When delete, they are not removed, they are just set in a deleted state' AFTER `updatedAt`,
|
|
ADD `version` int NOT NULL DEFAULT '2' AFTER `deleted`,
|
|
CHANGE `name` `name` varchar(256) COLLATE 'utf8mb4_0900_ai_ci' NULL COMMENT 'Name of the migration' AFTER `version`,
|
|
CHANGE `terminated` `terminated` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'if the migration is well terminated or not' AFTER `name`,
|
|
CHANGE `stepId` `stepId` int NULL COMMENT 'index in the migration progression' AFTER `terminated`,
|
|
CHANGE `count` `count` int NULL COMMENT 'number of element in the migration' AFTER `stepId`,
|
|
CHANGE `log` `log` text COLLATE 'utf8mb3_general_ci' NULL COMMENT 'Log generate by the migration' AFTER `count`;
|
|
""");
|
|
|
|
addAction("""
|
|
ALTER TABLE `album`
|
|
CHANGE `id` `id` bigint NOT NULL COMMENT 'Primary key of the base' AUTO_INCREMENT FIRST,
|
|
CHANGE `create_date` `createdAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'Create time of the object' AFTER `id`,
|
|
CHANGE `modify_date` `updatedAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'When update the object' AFTER `createdAt`,
|
|
CHANGE `deleted` `deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'When delete, they are not removed, they are just set in a deleted state' AFTER `updatedAt`,
|
|
CHANGE `name` `name` varchar(256) COLLATE 'utf8mb4_0900_ai_ci' NULL AFTER `deleted`,
|
|
CHANGE `description` `description` text COLLATE 'utf8mb3_general_ci' NULL AFTER `name`,
|
|
CHANGE `publication` `publication` date NULL AFTER `description`;
|
|
""");
|
|
addAction("""
|
|
ALTER TABLE `album_link_cover`
|
|
CHANGE `create_date` `createdAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) AFTER `id`,
|
|
CHANGE `modify_date` `updatedAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) AFTER `createdAt`,
|
|
CHANGE `deleted` `deleted` tinyint(1) NOT NULL DEFAULT '0' AFTER `updatedAt`,
|
|
CHANGE `album_id` `object1id` bigint NOT NULL AFTER `deleted`,
|
|
CHANGE `cover_id` `object2id` bigint NOT NULL AFTER `object1id`;
|
|
""");
|
|
addAction("""
|
|
ALTER TABLE `artist`
|
|
CHANGE `id` `id` bigint NOT NULL COMMENT 'Primary key of the base' AUTO_INCREMENT FIRST,
|
|
CHANGE `create_date` `createdAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'Create time of the object' AFTER `id`,
|
|
CHANGE `modify_date` `updatedAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'When update the object' AFTER `createdAt`,
|
|
CHANGE `deleted` `deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'When delete, they are not removed, they are just set in a deleted state' AFTER `updatedAt`,
|
|
CHANGE `firstName` `firstName` varchar(256) COLLATE 'utf8mb4_0900_ai_ci' NULL AFTER `description`,
|
|
CHANGE `surname` `surname` varchar(256) COLLATE 'utf8mb4_0900_ai_ci' NULL AFTER `firstName`,
|
|
CHANGE `birth` `birth` date NULL AFTER `surname`,
|
|
CHANGE `death` `death` date NULL AFTER `birth`;
|
|
""");
|
|
addAction("""
|
|
ALTER TABLE `artist_link_cover`
|
|
CHANGE `create_date` `createdAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) AFTER `id`,
|
|
CHANGE `modify_date` `updatedAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) AFTER `createdAt`,
|
|
CHANGE `deleted` `deleted` tinyint(1) NOT NULL DEFAULT '0' AFTER `updatedAt`,
|
|
CHANGE `artist_id` `object1id` bigint NOT NULL AFTER `deleted`,
|
|
CHANGE `cover_id` `object2id` bigint NOT NULL AFTER `object1id`;
|
|
""");
|
|
addAction("""
|
|
ALTER TABLE `data`
|
|
CHANGE `id` `id` bigint NOT NULL COMMENT 'Primary key of the base' AUTO_INCREMENT FIRST,
|
|
CHANGE `create_date` `createdAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'Create time of the object' AFTER `id`,
|
|
CHANGE `modify_date` `updatedAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'When update the object' AFTER `createdAt`,
|
|
CHANGE `deleted` `deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'When delete, they are not removed, they are just set in a deleted state' AFTER `updatedAt`,
|
|
CHANGE `sha512` `sha512` varchar(128) COLLATE 'utf8mb4_0900_ai_ci' NOT NULL COMMENT 'Sha512 of the data' AFTER `deleted`,
|
|
CHANGE `mimeType` `mimeType` varchar(128) COLLATE 'utf8mb4_0900_ai_ci' NOT NULL COMMENT 'Mime -type of the media' AFTER `sha512`,
|
|
CHANGE `size` `size` bigint NOT NULL COMMENT 'Size in Byte of the data' AFTER `mimeType`;
|
|
""");
|
|
addAction("""
|
|
ALTER TABLE `gender`
|
|
CHANGE `id` `id` bigint NOT NULL COMMENT 'Primary key of the base' AUTO_INCREMENT FIRST,
|
|
CHANGE `create_date` `createdAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'Create time of the object' AFTER `id`,
|
|
CHANGE `modify_date` `updatedAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'When update the object' AFTER `createdAt`,
|
|
CHANGE `name` `name` varchar(256) COLLATE 'utf8mb4_0900_ai_ci' NULL AFTER `deleted`,
|
|
CHANGE `description` `description` text COLLATE 'utf8mb3_general_ci' NULL AFTER `name`;
|
|
""");
|
|
addAction("""
|
|
ALTER TABLE `gender_link_cover`
|
|
CHANGE `create_date` `createdAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) AFTER `id`,
|
|
CHANGE `modify_date` `updatedAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) AFTER `createdAt`,
|
|
CHANGE `deleted` `deleted` tinyint(1) NOT NULL DEFAULT '0' AFTER `updatedAt`,
|
|
CHANGE `gender_id` `object1id` bigint NOT NULL AFTER `deleted`,
|
|
CHANGE `cover_id` `object2id` bigint NOT NULL AFTER `object1id`;
|
|
""");
|
|
addAction("""
|
|
ALTER TABLE `playlist`
|
|
CHANGE `id` `id` bigint NOT NULL COMMENT 'Primary key of the base' AUTO_INCREMENT FIRST,
|
|
CHANGE `create_date` `createdAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'Create time of the object' AFTER `id`,
|
|
CHANGE `modify_date` `updatedAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'When update the object' AFTER `createdAt`,
|
|
CHANGE `name` `name` varchar(256) COLLATE 'utf8mb4_0900_ai_ci' NULL AFTER `deleted`,
|
|
CHANGE `description` `description` text COLLATE 'utf8mb3_general_ci' NULL AFTER `name`;
|
|
""");
|
|
addAction("""
|
|
ALTER TABLE `playlist_link_cover`
|
|
CHANGE `create_date` `createdAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) AFTER `id`,
|
|
CHANGE `modify_date` `updatedAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) AFTER `createdAt`,
|
|
CHANGE `deleted` `deleted` tinyint(1) NOT NULL DEFAULT '0' AFTER `updatedAt`,
|
|
CHANGE `playlist_id` `object1id` bigint NOT NULL AFTER `deleted`,
|
|
CHANGE `cover_id` `object2id` bigint NOT NULL AFTER `object1id`;
|
|
""");
|
|
addAction("""
|
|
ALTER TABLE `playlist_link_track`
|
|
CHANGE `create_date` `createdAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) AFTER `id`,
|
|
CHANGE `modify_date` `updatedAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) AFTER `createdAt`,
|
|
CHANGE `deleted` `deleted` tinyint(1) NOT NULL DEFAULT '0' AFTER `updatedAt`,
|
|
CHANGE `playlist_id` `object1id` bigint NOT NULL AFTER `deleted`,
|
|
CHANGE `track_id` `object2id` bigint NOT NULL AFTER `object1id`;
|
|
""");
|
|
addAction("""
|
|
ALTER TABLE `track`
|
|
CHANGE `id` `id` bigint NOT NULL COMMENT 'Primary key of the base' AUTO_INCREMENT FIRST,
|
|
CHANGE `create_date` `createdAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'Create time of the object' AFTER `id`,
|
|
CHANGE `modify_date` `updatedAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'When update the object' AFTER `createdAt`,
|
|
CHANGE `deleted` `deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'When delete, they are not removed, they are just set in a deleted state' AFTER `updatedAt`,
|
|
CHANGE `name` `name` varchar(256) COLLATE 'utf8mb4_0900_ai_ci' NULL AFTER `deleted`,
|
|
CHANGE `description` `description` text COLLATE 'utf8mb3_general_ci' NULL AFTER `name`,
|
|
CHANGE `genderId` `genderId` bigint NULL AFTER `description`,
|
|
CHANGE `albumId` `albumId` bigint NULL AFTER `genderId`,
|
|
CHANGE `track` `track` bigint NULL AFTER `albumId`,
|
|
CHANGE `dataId` `dataId` bigint NULL AFTER `track`,
|
|
CHANGE `artists` `artists` text COLLATE 'utf8mb4_0900_ai_ci' NULL AFTER `dataId`;
|
|
""");
|
|
addAction("""
|
|
ALTER TABLE `track_link_cover`
|
|
CHANGE `create_date` `createdAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) AFTER `id`,
|
|
CHANGE `modify_date` `updatedAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) AFTER `createdAt`,
|
|
CHANGE `deleted` `deleted` tinyint(1) NOT NULL DEFAULT '0' AFTER `updatedAt`,
|
|
CHANGE `track_id` `object1id` bigint NOT NULL AFTER `deleted`,
|
|
CHANGE `cover_id` `object2id` bigint NOT NULL AFTER `object1id`;
|
|
""");
|
|
addAction("""
|
|
ALTER TABLE `user`
|
|
CHANGE `id` `id` bigint NOT NULL COMMENT 'Primary key of the base' AUTO_INCREMENT FIRST,
|
|
CHANGE `create_date` `createdAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'Create time of the object' AFTER `id`,
|
|
CHANGE `modify_date` `updatedAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'When update the object' AFTER `createdAt`,
|
|
CHANGE `deleted` `deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'When delete, they are not removed, they are just set in a deleted state' AFTER `updatedAt`,
|
|
CHANGE `login` `login` varchar(128) COLLATE 'utf8mb4_0900_ai_ci' NULL AFTER `deleted`,
|
|
CHANGE `lastConnection` `lastConnection` timestamp(3) NULL AFTER `login`,
|
|
CHANGE `admin` `admin` tinyint(1) NOT NULL DEFAULT '0' AFTER `lastConnection`,
|
|
CHANGE `blocked` `blocked` tinyint(1) NOT NULL DEFAULT '0' AFTER `admin`,
|
|
CHANGE `removed` `removed` tinyint(1) NOT NULL DEFAULT '0' AFTER `blocked`;
|
|
""");
|
|
addAction("""
|
|
CREATE TABLE `user_link_cover` (
|
|
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'Primary key of the base' ,
|
|
`createdAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT 'Create time of the object' ,
|
|
`updatedAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3) COMMENT 'When update the object' ,
|
|
`deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'When delete, they are not removed, they are just set in a deleted state' ,
|
|
`object1Id` bigint NOT NULL COMMENT 'Object reference 1' ,
|
|
`object2Id` bigint NOT NULL COMMENT 'Object reference 2' ,
|
|
PRIMARY KEY (`id`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
""");
|
|
}
|
|
|
|
}
|