1、部署
parent
22b7b2b5b7
commit
262c91765c
|
|
@ -0,0 +1,55 @@
|
|||
package com.zcloud.personnel.positioning.config;
|
||||
|
||||
import org.flywaydb.core.api.MigrationInfo;
|
||||
import org.flywaydb.core.api.MigrationVersion;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.autoconfigure.flyway.FlywayMigrationStrategy;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Recovers the known partial MySQL migration left by V20260710_02.
|
||||
*
|
||||
* <p>The migration is idempotent and can be safely rerun after Flyway removes
|
||||
* its failed history entry. Other failed migrations are never repaired
|
||||
* automatically so that new database problems still stop application startup.</p>
|
||||
*/
|
||||
@Configuration
|
||||
public class FlywayRecoveryConfiguration {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(FlywayRecoveryConfiguration.class);
|
||||
private static final MigrationVersion RECOVERABLE_VERSION = MigrationVersion.fromVersion("20260710.02");
|
||||
|
||||
@Bean
|
||||
public FlywayMigrationStrategy flywayMigrationStrategy() {
|
||||
return flyway -> {
|
||||
List<MigrationInfo> failedMigrations = Arrays.stream(flyway.info().all())
|
||||
.filter(migration -> migration.getState().isFailed())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (!failedMigrations.isEmpty()) {
|
||||
boolean onlyKnownFailure = failedMigrations.size() == 1
|
||||
&& RECOVERABLE_VERSION.equals(failedMigrations.get(0).getVersion());
|
||||
if (!onlyKnownFailure) {
|
||||
String failedVersions = failedMigrations.stream()
|
||||
.map(migration -> migration.getVersion() == null
|
||||
? migration.getDescription()
|
||||
: migration.getVersion().toString())
|
||||
.collect(Collectors.joining(", "));
|
||||
throw new IllegalStateException(
|
||||
"Flyway contains unsupported failed migrations: " + failedVersions);
|
||||
}
|
||||
|
||||
LOGGER.warn("Repairing known failed Flyway migration {} before retry", RECOVERABLE_VERSION);
|
||||
flyway.repair();
|
||||
}
|
||||
|
||||
flyway.migrate();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -2,9 +2,9 @@ nacos:
|
|||
url: prod-nacos:8848
|
||||
namespace: jjb-dragon
|
||||
application:
|
||||
name: zcloud-gbs-personnel-positioning
|
||||
name: zcloud-gbs-personnel-position
|
||||
version:
|
||||
gateway: personnelPositioning
|
||||
gateway: personnelPosition
|
||||
cn-name: 人员定位
|
||||
spring:
|
||||
application:
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ nacos:
|
|||
url: 192.168.20.100:30290
|
||||
namespace: jjb-dragon
|
||||
application:
|
||||
name: zcloud-gbs-personnel-positioning
|
||||
name: zcloud-gbs-personnel-position
|
||||
version:
|
||||
gateway: personnelPositioning
|
||||
gateway: personnelPosition
|
||||
cn-name: 人员定位
|
||||
spring:
|
||||
application:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
mysql:
|
||||
db: ${spring.application.name}
|
||||
db: zcloud-gbs-personnel-position
|
||||
spring:
|
||||
shardingsphere:
|
||||
druid:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
CREATE DATABASE IF NOT EXISTS `zcloud-gbs-personnel-positioning`
|
||||
CREATE DATABASE IF NOT EXISTS `zcloud-gbs-personnel-position`
|
||||
DEFAULT CHARACTER SET utf8mb4;
|
||||
|
||||
USE `zcloud-gbs-personnel-positioning`;
|
||||
USE `zcloud-gbs-personnel-position`;
|
||||
|
||||
-- 实时位置、轨迹点不落 MySQL;页面实时查询直接走 FindS,必要时使用 Redis 短缓存。
|
||||
-- MySQL 只保存 GBS 侧业务配置、三方映射、告警闭环和同步审计。
|
||||
|
|
|
|||
Loading…
Reference in New Issue