Skip to content

Commit

Permalink
feat:使用Liquibase管理数据库表变更记录
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyueyi committed Dec 9, 2022
1 parent 44d5dbe commit c65cbda
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 375 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ mvn clean install -DskipTests=true -Pprod
- application.yml: 主配置文件入口
- application-config.yml: 全局的站点信息配置文件
- logback-spring.xml: 日志打印相关配置文件
- schema-all.sql: 项目中所有表结构定义sql文件
- init-data.sql: 初始化数据sql文件
- schema.sql, test-data.sql: 开发阶段的sql文件,后续会删除,不用关注
- liquibase: 由liquibase进行数据库表结构管理
- resources-env
- xxx/application-dal.yml: 定义数据库相关的配置信息
- xxx/application-image.yml: 定义上传图片的相关配置信息
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static EnvEnum getEnv() {
}
}
}
Assert.isTrue(env != null, "env.name环境配置必然存在!");
Assert.isTrue(env != null, "env.name环境配置必须存在!");
return env;
}
}
5 changes: 5 additions & 0 deletions forum-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
<version>2.6.3</version>
</dependency>

<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ public DataSourceInitializer dataSourceInitializer(final DataSource dataSource)

private DatabasePopulator databasePopulator() {
final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
populator.addScripts(schemaSql);
populator.addScripts(initData);
populator.setSeparator(";");
// 下面这种是根据sql文件来进行初始化;改成 liquibase 之后不再使用这种方案,由liquibase来统一管理表结构数据变更
// populator.addScripts(schemaSql);
// populator.addScripts(initData);
// populator.setSeparator(";");
return populator;
}

Expand Down
5 changes: 4 additions & 1 deletion forum-web/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ spring:
mvc:
async:
request-timeout:
liquibase:
change-log: classpath:liquibase/master.xml
enabled: true

security:
salt: tech_π # 密码加盐, 更安全的做法是每个用户的密码使用独立的盐,并将其保存在用户表中
Expand All @@ -17,7 +20,7 @@ security:

# 默认的数据库名
database:
name: forum
name: tech_pai

# mybatis 相关统一配置
mybatis-plus:
Expand Down
23 changes: 0 additions & 23 deletions forum-web/src/main/resources/dev/init-dict.sql

This file was deleted.

Loading

0 comments on commit c65cbda

Please sign in to comment.