From 166272ad11ae283e179c288ef4ae1b306ed9a589 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Wed, 1 Feb 2023 15:54:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=9B=B4=E6=96=B0=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/genersoft/iot/vmp/conf/FlywayConfig.java | 7 +++++++ .../java/com/genersoft/iot/vmp/conf/UserSetting.java | 9 +++++++++ src/main/resources/all-application.yml | 2 ++ 3 files changed, 18 insertions(+) diff --git a/src/main/java/com/genersoft/iot/vmp/conf/FlywayConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/FlywayConfig.java index b73acb94..6133694d 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/FlywayConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/FlywayConfig.java @@ -21,8 +21,15 @@ public class FlywayConfig { @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" diff --git a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java index a0956cc8..be7d5af4 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java @@ -46,6 +46,7 @@ public class UserSetting { private Boolean syncChannelOnDeviceOnline = Boolean.FALSE; private Boolean sipLog = Boolean.FALSE; + private Boolean syncDb = Boolean.TRUE; private String serverId = "000000"; @@ -216,4 +217,12 @@ public class UserSetting { public void setSipLog(Boolean sipLog) { this.sipLog = sipLog; } + + public Boolean getSyncDb() { + return syncDb; + } + + public void setSyncDb(Boolean syncDb) { + this.syncDb = syncDb; + } } diff --git a/src/main/resources/all-application.yml b/src/main/resources/all-application.yml index e3c23604..3908019f 100644 --- a/src/main/resources/all-application.yml +++ b/src/main/resources/all-application.yml @@ -199,6 +199,8 @@ user-settings: sip-use-source-ip-as-remote-address: false # 是否开启sip日志 sip-log: true + # 自动数据库升级,保证表结构完整 + sync-db: true # 关闭在线文档(生产环境建议关闭) springdoc: