Skip to content

Commit

Permalink
support flyway control
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzm0809 committed Mar 27, 2024
1 parent 0eec1d4 commit dca9d1f
Show file tree
Hide file tree
Showing 7 changed files with 9,405 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dinky-admin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
Expand Down
32 changes: 32 additions & 0 deletions dinky-admin/src/main/resources/application-flyway.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

spring:
flyway:
enabled: true # 是否启用
group: true # 启用分组
locations:
- classpath:db/migration/${spring.profiles.active}
table: _dinky_flyway_schema_history
placeholder-replacement: false # 占位符替换
baseline-on-migrate: true # 迁移时基线
baseline-version: 1.0.1 # 基线版本
validate-on-migrate: true # 迁移时验证
placeholder-prefix: '##{'
placeholder-suffix: '}##'
fail-on-missing-locations: true # 不存在的迁移文件是否抛出异常

18 changes: 18 additions & 0 deletions dinky-admin/src/main/resources/db/migration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@


## 前置要求

- 数据库版本: MySQL 5.7+
- 必须有 mysql/postgresql 连接包


## 数据库脚本规则
- V 开头的代表发布版本; 规则: `V{版本号}__{描述}.sql`
- R 开头的代表回滚版本; 规则: `R{版本号}__{描述}.sql`

## 命名规则

- V{版本号}_{描述}.sql eg: V1.0.2__modify-ddl.sql
- R{版本号}_{描述}.sql eg: R1.0.2__modify-ddl.sql

**注意:** V{版本号}__{描述}.sql 中间是两个下划线,固定规则,不符合规则将无法执行
3,169 changes: 3,169 additions & 0 deletions dinky-admin/src/main/resources/db/migration/h2/V1.0.1__baseline.sql

Large diffs are not rendered by default.

2,028 changes: 2,028 additions & 0 deletions dinky-admin/src/main/resources/db/migration/mysql/V1.0.1__baseline.sql

Large diffs are not rendered by default.

Loading

0 comments on commit dca9d1f

Please sign in to comment.