去除数据库自动更新,自动更新会导致wvp在arm架构服务上无法启动
This commit is contained in:
parent
166272ad11
commit
aa3cec0dfc
7
pom.xml
7
pom.xml
@ -242,13 +242,8 @@
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<!-- <scope>test</scope>-->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-core</artifactId>
|
||||
<version>7.15.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
<build>
|
||||
|
@ -1,64 +0,0 @@
|
||||
package com.genersoft.iot.vmp.conf;
|
||||
|
||||
import org.flywaydb.core.Flyway;
|
||||
import org.flywaydb.core.api.FlywayException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
/**
|
||||
* 数据库自动升级脚本
|
||||
*/
|
||||
@Configuration
|
||||
public class FlywayConfig {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(FlywayConfig.class);
|
||||
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Autowired
|
||||
private UserSetting userSetting;
|
||||
|
||||
@PostConstruct
|
||||
public void migrate() {
|
||||
if (!userSetting.getSyncDb()) {
|
||||
logger.info("[数据库自动升级] 已关闭");
|
||||
return;
|
||||
}
|
||||
Flyway flyway = Flyway.configure()
|
||||
.dataSource(dataSource)
|
||||
.locations("db/migration")//sql文件名称规则:"V20210625.17.30__V1.0.sql"
|
||||
// 自动创建flyway元数据表标识
|
||||
.baselineOnMigrate(true)
|
||||
.baselineVersion("0")
|
||||
// 禁止flyway执行清理
|
||||
.cleanDisabled(true)
|
||||
.table("flyway_schema_history_wvp")
|
||||
// 对于开发环境, 可能是多人协作开发, 很可能先 apply 了自己本地的最新 SQL 代码, 然后发现其他同事早先时候提交的 SQL 代码还没有 apply,
|
||||
// 所以 开发环境应该设置 spring.flyway.outOfOrder=true, 这样 flyway 将能加载漏掉的老版本 SQL 文件;
|
||||
// 而生产环境应该设置 spring.flyway.outOfOrder=false
|
||||
.outOfOrder(true)
|
||||
.encoding("UTF-8")
|
||||
.load();
|
||||
try {
|
||||
flyway.migrate();
|
||||
} catch (FlywayException e) {
|
||||
logger.error("[数据库自动升级]配置第一次加载出错", e);
|
||||
try {
|
||||
flyway.repair();//生成版本记录表
|
||||
logger.info("[数据库自动升级]配置修复成功");
|
||||
flyway.migrate();
|
||||
logger.info("[数据库自动升级]配置重新加载成功");
|
||||
} catch (Exception e1) {
|
||||
logger.error("[数据库自动升级]配置第二次加载出错", e1);
|
||||
throw e1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -46,7 +46,6 @@ public class UserSetting {
|
||||
private Boolean syncChannelOnDeviceOnline = Boolean.FALSE;
|
||||
|
||||
private Boolean sipLog = Boolean.FALSE;
|
||||
private Boolean syncDb = Boolean.TRUE;
|
||||
|
||||
private String serverId = "000000";
|
||||
|
||||
@ -217,12 +216,4 @@ public class UserSetting {
|
||||
public void setSipLog(Boolean sipLog) {
|
||||
this.sipLog = sipLog;
|
||||
}
|
||||
|
||||
public Boolean getSyncDb() {
|
||||
return syncDb;
|
||||
}
|
||||
|
||||
public void setSyncDb(Boolean syncDb) {
|
||||
this.syncDb = syncDb;
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
package com.genersoft.iot.vmp.storager.dao;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
@ -20,7 +21,7 @@ public interface DeviceAlarmMapper {
|
||||
int add(DeviceAlarm alarm);
|
||||
|
||||
|
||||
@Select(value = {" <script>" +
|
||||
@Select( value = {" <script>" +
|
||||
" SELECT * FROM device_alarm " +
|
||||
" WHERE 1=1 " +
|
||||
" <if test=\"deviceId != null\" > AND deviceId = #{deviceId}</if>" +
|
||||
|
Loading…
Reference in New Issue
Block a user