1、部署

master
shenzhidan 2026-07-13 17:12:57 +08:00
parent 22b7b2b5b7
commit 262c91765c
5 changed files with 63 additions and 8 deletions

View File

@ -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();
};
}
}

View File

@ -2,9 +2,9 @@ nacos:
url: prod-nacos:8848 url: prod-nacos:8848
namespace: jjb-dragon namespace: jjb-dragon
application: application:
name: zcloud-gbs-personnel-positioning name: zcloud-gbs-personnel-position
version: version:
gateway: personnelPositioning gateway: personnelPosition
cn-name: 人员定位 cn-name: 人员定位
spring: spring:
application: application:

View File

@ -2,9 +2,9 @@ nacos:
url: 192.168.20.100:30290 url: 192.168.20.100:30290
namespace: jjb-dragon namespace: jjb-dragon
application: application:
name: zcloud-gbs-personnel-positioning name: zcloud-gbs-personnel-position
version: version:
gateway: personnelPositioning gateway: personnelPosition
cn-name: 人员定位 cn-name: 人员定位
spring: spring:
application: application:

View File

@ -1,5 +1,5 @@
mysql: mysql:
db: ${spring.application.name} db: zcloud-gbs-personnel-position
spring: spring:
shardingsphere: shardingsphere:
druid: druid:

View File

@ -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; DEFAULT CHARACTER SET utf8mb4;
USE `zcloud-gbs-personnel-positioning`; USE `zcloud-gbs-personnel-position`;
-- 实时位置、轨迹点不落 MySQL页面实时查询直接走 FindS必要时使用 Redis 短缓存。 -- 实时位置、轨迹点不落 MySQL页面实时查询直接走 FindS必要时使用 Redis 短缓存。
-- MySQL 只保存 GBS 侧业务配置、三方映射、告警闭环和同步审计。 -- MySQL 只保存 GBS 侧业务配置、三方映射、告警闭环和同步审计。