增加数据库自动更新开关
parent
7470e1fe8e
commit
166272ad11
|
@ -21,8 +21,15 @@ public class FlywayConfig {
|
||||||
@Autowired
|
@Autowired
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserSetting userSetting;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void migrate() {
|
public void migrate() {
|
||||||
|
if (!userSetting.getSyncDb()) {
|
||||||
|
logger.info("[数据库自动升级] 已关闭");
|
||||||
|
return;
|
||||||
|
}
|
||||||
Flyway flyway = Flyway.configure()
|
Flyway flyway = Flyway.configure()
|
||||||
.dataSource(dataSource)
|
.dataSource(dataSource)
|
||||||
.locations("db/migration")//sql文件名称规则:"V20210625.17.30__V1.0.sql"
|
.locations("db/migration")//sql文件名称规则:"V20210625.17.30__V1.0.sql"
|
||||||
|
|
|
@ -46,6 +46,7 @@ public class UserSetting {
|
||||||
private Boolean syncChannelOnDeviceOnline = Boolean.FALSE;
|
private Boolean syncChannelOnDeviceOnline = Boolean.FALSE;
|
||||||
|
|
||||||
private Boolean sipLog = Boolean.FALSE;
|
private Boolean sipLog = Boolean.FALSE;
|
||||||
|
private Boolean syncDb = Boolean.TRUE;
|
||||||
|
|
||||||
private String serverId = "000000";
|
private String serverId = "000000";
|
||||||
|
|
||||||
|
@ -216,4 +217,12 @@ public class UserSetting {
|
||||||
public void setSipLog(Boolean sipLog) {
|
public void setSipLog(Boolean sipLog) {
|
||||||
this.sipLog = sipLog;
|
this.sipLog = sipLog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Boolean getSyncDb() {
|
||||||
|
return syncDb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSyncDb(Boolean syncDb) {
|
||||||
|
this.syncDb = syncDb;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,6 +199,8 @@ user-settings:
|
||||||
sip-use-source-ip-as-remote-address: false
|
sip-use-source-ip-as-remote-address: false
|
||||||
# 是否开启sip日志
|
# 是否开启sip日志
|
||||||
sip-log: true
|
sip-log: true
|
||||||
|
# 自动数据库升级,保证表结构完整
|
||||||
|
sync-db: true
|
||||||
|
|
||||||
# 关闭在线文档(生产环境建议关闭)
|
# 关闭在线文档(生产环境建议关闭)
|
||||||
springdoc:
|
springdoc:
|
||||||
|
|
Loading…
Reference in New Issue