[DEV] correct migration
This commit is contained in:
parent
2ba8d21bde
commit
a78c3f5c1f
@ -51,10 +51,10 @@ public class WebLauncher {
|
||||
protected ResourceConfig rc = null;
|
||||
HttpServer server = null;
|
||||
protected BackupEngine backupEngine = new BackupEngine("./backup", StoreMode.JSON);
|
||||
|
||||
|
||||
public WebLauncher() {
|
||||
ConfigBaseVariable.bdDatabase = "karso";
|
||||
|
||||
|
||||
this.backupEngine.addClass(Migration.class);
|
||||
this.backupEngine.addClass(Settings.class);
|
||||
this.backupEngine.addClass(UserAuth.class);
|
||||
@ -62,24 +62,24 @@ public class WebLauncher {
|
||||
this.backupEngine.addClass(ApplicationToken.class);
|
||||
this.backupEngine.addClass(RightDescription.class);
|
||||
this.backupEngine.addClass(Right.class);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static URI getBaseURI() {
|
||||
return UriBuilder.fromUri(ConfigBaseVariable.getlocalAddress()).build();
|
||||
}
|
||||
|
||||
|
||||
public static void main(final String[] args) throws Exception {
|
||||
WebLauncher.LOGGER.info("[START] application wake UP");
|
||||
final WebLauncher launcher = new WebLauncher();
|
||||
launcher.migrateDB();
|
||||
|
||||
|
||||
launcher.process();
|
||||
WebLauncher.LOGGER.info("end-configure the server & wait finish process:");
|
||||
Thread.currentThread().join();
|
||||
WebLauncher.LOGGER.info("STOP the REST server:");
|
||||
}
|
||||
|
||||
|
||||
public void migrateDB() throws Exception {
|
||||
WebLauncher.LOGGER.info("Create migration engine");
|
||||
final MigrationEngine migrationEngine = new MigrationEngine();
|
||||
@ -93,7 +93,7 @@ public class WebLauncher {
|
||||
migrationEngine.migrateWaitAdmin(GlobalConfiguration.dbConfig);
|
||||
WebLauncher.LOGGER.info("Migrate the DB [STOP]");
|
||||
}
|
||||
|
||||
|
||||
public void process() throws InterruptedException {
|
||||
try {
|
||||
JWTWrapper.initLocalToken(ConfigVariable.getUUIDKeyRoot());
|
||||
@ -104,7 +104,7 @@ public class WebLauncher {
|
||||
Thread.sleep(10000);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// ===================================================================
|
||||
// Configure resources
|
||||
// ===================================================================
|
||||
@ -132,7 +132,7 @@ public class WebLauncher {
|
||||
this.rc.register(JacksonFeature.class);
|
||||
// enable this to show low level request
|
||||
//rc.property(LoggingFeature.LOGGING_FEATURE_LOGGER_LEVEL_SERVER, Level.WARNING.getName());
|
||||
|
||||
|
||||
this.server = GrizzlyHttpServerFactory.createHttpServer(getBaseURI(), this.rc);
|
||||
final HttpServer serverLink = this.server;
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
|
||||
@ -142,7 +142,7 @@ public class WebLauncher {
|
||||
serverLink.shutdownNow();
|
||||
}
|
||||
}, "shutdownHook"));
|
||||
|
||||
|
||||
// ===================================================================
|
||||
// run JERSEY
|
||||
// ===================================================================
|
||||
@ -154,11 +154,11 @@ public class WebLauncher {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void stop() {
|
||||
if (this.server != null) {
|
||||
this.server.shutdownNow();
|
||||
|
||||
|
||||
while (this.server.isStarted()) {
|
||||
LOGGER.info("wait stop");
|
||||
try {
|
||||
|
@ -3,20 +3,35 @@ package org.kar.karso.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 "reorder the migration for the new API of archidata";
|
||||
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 `application`
|
||||
CHANGE `id` `id` bigint NOT NULL COMMENT 'Primary key of the base' AUTO_INCREMENT FIRST,
|
||||
@ -38,11 +53,11 @@ public class Migration20231126 extends MigrationSqlStep {
|
||||
CHANGE `updatedAt` `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 `parentId` `parentId` bigint NOT NULL AFTER `deleted`,
|
||||
CHANGE `name` `name` varchar(255) COLLATE 'utf8mb3_general_ci' NOT NULL AFTER `parentId`,
|
||||
CHANGE `name` `name` text COLLATE 'utf8mb3_general_ci' NOT NULL AFTER `parentId`,
|
||||
CHANGE `endValidityTime` `endValidityTime` timestamp(3) NOT NULL AFTER `name`,
|
||||
CHANGE `token` `token` varchar(255) COLLATE 'utf8mb3_general_ci' NOT NULL AFTER `endValidityTime`;
|
||||
CHANGE `token` `token` text COLLATE 'utf8mb3_general_ci' NOT NULL AFTER `endValidityTime`;
|
||||
""");
|
||||
|
||||
|
||||
addAction("""
|
||||
ALTER TABLE `right`
|
||||
CHANGE `id` `id` bigint NOT NULL COMMENT 'Primary key of the base' AUTO_INCREMENT FIRST,
|
||||
@ -54,7 +69,7 @@ public class Migration20231126 extends MigrationSqlStep {
|
||||
CHANGE `rightDescriptionId` `rightDescriptionId` bigint NOT NULL COMMENT 'rightDescription-ID of the right description' AFTER `userId`,
|
||||
CHANGE `value` `value` varchar(1024) COLLATE 'utf8mb4_0900_ai_ci' NOT NULL COMMENT 'Value of the right' AFTER `rightDescriptionId`;
|
||||
""");
|
||||
|
||||
|
||||
addAction("""
|
||||
ALTER TABLE `rightDescription`
|
||||
CHANGE `id` `id` bigint NOT NULL COMMENT 'Primary key of the base' AUTO_INCREMENT FIRST,
|
||||
@ -68,7 +83,7 @@ public class Migration20231126 extends MigrationSqlStep {
|
||||
CHANGE `defaultValue` `defaultValue` varchar(1024) COLLATE 'utf8mb4_0900_ai_ci' NULL COMMENT 'default value if Never set' AFTER `description`,
|
||||
CHANGE `type` `type` varchar(16) COLLATE 'utf8mb4_0900_ai_ci' NOT NULL DEFAULT 'BOOLEAN' COMMENT 'Type of the property' AFTER `defaultValue`;
|
||||
""");
|
||||
|
||||
|
||||
addAction("""
|
||||
ALTER TABLE `settings`
|
||||
CHANGE `id` `id` bigint NOT NULL COMMENT 'Primary key of the base' AUTO_INCREMENT FIRST,
|
||||
@ -78,9 +93,9 @@ public class Migration20231126 extends MigrationSqlStep {
|
||||
CHANGE `key` `key` varchar(512) COLLATE 'utf8mb4_0900_ai_ci' NOT NULL AFTER `deleted`,
|
||||
CHANGE `right` `right` varchar(6) COLLATE 'utf8mb4_0900_ai_ci' NOT NULL DEFAULT 'rw----' COMMENT 'Right for the specific element(ADMIN [rw] USER [rw] other [rw])' AFTER `key`,
|
||||
CHANGE `type` `type` varchar(10) COLLATE 'utf8mb4_0900_ai_ci' NOT NULL COMMENT 'Type Of the data' AFTER `right`,
|
||||
CHANGE `value` `value` varchar(255) COLLATE 'utf8mb3_general_ci' NOT NULL COMMENT 'Value of the configuration' AFTER `type`;
|
||||
CHANGE `value` `value` text COLLATE 'utf8mb3_general_ci' NOT NULL COMMENT 'Value of the configuration' AFTER `type`;
|
||||
""");
|
||||
|
||||
|
||||
addAction("""
|
||||
ALTER TABLE `user`
|
||||
CHANGE `id` `id` bigint NOT NULL COMMENT 'Primary key of the base' AUTO_INCREMENT FIRST,
|
||||
@ -98,7 +113,7 @@ public class Migration20231126 extends MigrationSqlStep {
|
||||
CHANGE `newEmail` `newEmail` varchar(512) COLLATE 'utf8mb4_0900_ai_ci' NULL AFTER `emailValidate`,
|
||||
CHANGE `avatar` `avatar` tinyint(1) NOT NULL DEFAULT '0' AFTER `newEmail`;
|
||||
""");
|
||||
|
||||
|
||||
addAction("""
|
||||
ALTER TABLE `user_link_application`
|
||||
CHANGE `createdAt` `createdAt` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) AFTER `id`,
|
||||
@ -108,7 +123,7 @@ public class Migration20231126 extends MigrationSqlStep {
|
||||
CHANGE `application_id` `object2id` bigint NOT NULL AFTER `object1id`,
|
||||
ADD FOREIGN KEY (`object1id`) REFERENCES `user` (`id`);
|
||||
""");
|
||||
|
||||
|
||||
addAction("""
|
||||
CREATE TABLE `user_link_cover` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'Primary key of the base' ,
|
||||
@ -120,7 +135,7 @@ public class Migration20231126 extends MigrationSqlStep {
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||
""");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user