Commit 166272ad11ae283e179c288ef4ae1b306ed9a589

Authored by 648540858
1 parent 7470e1fe

增加数据库自动更新开关

src/main/java/com/genersoft/iot/vmp/conf/FlywayConfig.java
@@ -21,8 +21,15 @@ public class FlywayConfig { @@ -21,8 +21,15 @@ public class FlywayConfig {
21 @Autowired 21 @Autowired
22 private DataSource dataSource; 22 private DataSource dataSource;
23 23
  24 + @Autowired
  25 + private UserSetting userSetting;
  26 +
24 @PostConstruct 27 @PostConstruct
25 public void migrate() { 28 public void migrate() {
  29 + if (!userSetting.getSyncDb()) {
  30 + logger.info("[数据库自动升级] 已关闭");
  31 + return;
  32 + }
26 Flyway flyway = Flyway.configure() 33 Flyway flyway = Flyway.configure()
27 .dataSource(dataSource) 34 .dataSource(dataSource)
28 .locations("db/migration")//sql文件名称规则:"V20210625.17.30__V1.0.sql" 35 .locations("db/migration")//sql文件名称规则:"V20210625.17.30__V1.0.sql"
src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java
@@ -46,6 +46,7 @@ public class UserSetting { @@ -46,6 +46,7 @@ public class UserSetting {
46 private Boolean syncChannelOnDeviceOnline = Boolean.FALSE; 46 private Boolean syncChannelOnDeviceOnline = Boolean.FALSE;
47 47
48 private Boolean sipLog = Boolean.FALSE; 48 private Boolean sipLog = Boolean.FALSE;
  49 + private Boolean syncDb = Boolean.TRUE;
49 50
50 private String serverId = "000000"; 51 private String serverId = "000000";
51 52
@@ -216,4 +217,12 @@ public class UserSetting { @@ -216,4 +217,12 @@ public class UserSetting {
216 public void setSipLog(Boolean sipLog) { 217 public void setSipLog(Boolean sipLog) {
217 this.sipLog = sipLog; 218 this.sipLog = sipLog;
218 } 219 }
  220 +
  221 + public Boolean getSyncDb() {
  222 + return syncDb;
  223 + }
  224 +
  225 + public void setSyncDb(Boolean syncDb) {
  226 + this.syncDb = syncDb;
  227 + }
219 } 228 }
src/main/resources/all-application.yml
@@ -199,6 +199,8 @@ user-settings: @@ -199,6 +199,8 @@ user-settings:
199 sip-use-source-ip-as-remote-address: false 199 sip-use-source-ip-as-remote-address: false
200 # 是否开启sip日志 200 # 是否开启sip日志
201 sip-log: true 201 sip-log: true
  202 + # 自动数据库升级,保证表结构完整
  203 + sync-db: true
202 204
203 # 关闭在线文档(生产环境建议关闭) 205 # 关闭在线文档(生产环境建议关闭)
204 springdoc: 206 springdoc: