Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
I
ils-spring-example
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
1
合并请求
1
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
ils-spring-example
Commits
3923b7e5
提交
3923b7e5
authored
7月 31, 2021
作者:
周联昌
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ils-service:将数据库变更引入 flyway
ils-spring-example:补充readme.md说明
上级
1a48a1c7
流水线
#304
已失败 于阶段
变更
5
流水线
1
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
59 行增加
和
5 行删除
+59
-5
README.md
README.md
+2
-3
pom.xml
ils-service/pom.xml
+5
-0
application-test.yml
ils-service/src/main/resources/application-test.yml
+20
-2
V0.0.0__Init_databases.sql
...rc/main/resources/db/migration/V0.0.0__Init_databases.sql
+30
-0
bootstrap.sql
ils-service/src/main/resources/db/old/bootstrap.sql
+2
-0
没有找到文件。
README.md
浏览文件 @
3923b7e5
...
@@ -20,6 +20,5 @@
...
@@ -20,6 +20,5 @@
*
model 已经 VO 里的类, 只要是会被作为返回值, 就需要用 swagger 的注释来解释.
*
model 已经 VO 里的类, 只要是会被作为返回值, 就需要用 swagger 的注释来解释.
## 数据库脚本
## 数据库脚本
*
数据库脚本都在 resource 的 db_migration 中, 只要一个微服务有自己独立的数据库.
*
数据库脚本都在 resource 的 db.migration 中, 只要一个微服务有自己独立的数据库.
*
其中 bootstrap 里包括完成的表单定义
*
其中 migration 里按照更新版本号来放 release 中数据库的更改脚本. 每个脚本的名字格式为 V
`版本号`
__
`描述内容`
.sql.
*
其中 migration 里按照月份来放该月 release 中数据库的更改脚本. 每个脚本的名字格式为 001.sql, 002.sql, 类推.
ils-service/pom.xml
浏览文件 @
3923b7e5
...
@@ -82,6 +82,11 @@
...
@@ -82,6 +82,11 @@
<artifactId>
fastjson
</artifactId>
<artifactId>
fastjson
</artifactId>
<version>
1.2.58
</version>
<version>
1.2.58
</version>
</dependency>
</dependency>
<dependency>
<groupId>
org.flywaydb
</groupId>
<artifactId>
flyway-core
</artifactId>
<version>
5.2.4
</version>
</dependency>
</dependencies>
</dependencies>
...
...
ils-service/src/main/resources/application-test.yml
浏览文件 @
3923b7e5
...
@@ -36,7 +36,7 @@ spring:
...
@@ -36,7 +36,7 @@ spring:
name
:
ilsexample
name
:
ilsexample
url
:
jdbc:mysql://localhost:3306/ilsexample?useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT%2B8
url
:
jdbc:mysql://localhost:3306/ilsexample?useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT%2B8
username
:
root
username
:
root
password
:
root1234
password
:
123456
driver-class-name
:
com.mysql.jdbc.Driver
driver-class-name
:
com.mysql.jdbc.Driver
filters
:
stat
filters
:
stat
maxActive
:
20
maxActive
:
20
...
@@ -53,11 +53,29 @@ spring:
...
@@ -53,11 +53,29 @@ spring:
poolPreparedStatements
:
true
poolPreparedStatements
:
true
maxOpenPreparedStatements
:
20
maxOpenPreparedStatements
:
20
initialize
:
false
initialize
:
false
flyway
:
# sql脚本迁移扫描的路径 默认是db/migration
locations
:
classpath:/db/migration
# 分隔版本标志符 默认是__
sql-migration-separator
:
__
# 文件的后缀名 默认是.sql
sql-migration-suffixes
:
.sql
# 开发环境设置为true 生产环境设置为false
out-of-order
:
true
# 数据库生成的迁移历史表名称 默认是flyway_schema_history
table
:
flyway_schema_history
# 开启或者关闭flyway
enabled
:
true
# 需要强调一点,在生产环境上必须关闭flyway:clean指令,因为一旦误操作,所有数据将会被清空
clean-disabled
:
true
# 告诉系统具体的baseline版本号 包括这条版本号在内的之前所有sql脚本,都不会在迁移时执行
baseline-version
:
-1
# 对于已经存在的项目,数据库中存在数据,这个时候我们需要通过设置baseline告诉flyway,这个baseline以及之前所有sql脚本都不要执行了
baseline-on-migrate
:
true
jpa
:
jpa
:
hibernate
:
hibernate
:
show-sql
:
true
show-sql
:
true
database-platform
:
org.hibernate.dialect.MySQLDialect
database-platform
:
org.hibernate.dialect.MySQLDialect
application
:
application
:
name
:
ils-example-service
name
:
ils-example-service
...
...
ils-service/src/main/resources/db/migration/V0.0.0__Init_databases.sql
0 → 100644
浏览文件 @
3923b7e5
-- -----------------------------------------------------
-- Table `ilsexample`.`device`
-- -----------------------------------------------------
CREATE
TABLE
IF
NOT
EXISTS
ilsexample
.
`device`
(
`id`
INT
(
11
)
NOT
NULL
AUTO_INCREMENT
,
`name`
VARCHAR
(
45
)
NULL
DEFAULT
NULL
COMMENT
'设备名'
,
`brand`
VARCHAR
(
45
)
NULL
DEFAULT
NULL
COMMENT
'品牌'
,
`model`
VARCHAR
(
45
)
NULL
DEFAULT
NULL
COMMENT
'模型'
,
`enabled`
TINYINT
(
4
)
NULL
DEFAULT
NULL
COMMENT
'激活'
,
`weight`
DOUBLE
NULL
DEFAULT
NULL
COMMENT
'重量
\n
'
,
`length`
INT
(
11
)
NULL
DEFAULT
NULL
COMMENT
'长度 cm'
,
`height`
INT
(
11
)
NULL
DEFAULT
NULL
COMMENT
'高度 cm'
,
PRIMARY
KEY
(
`id`
))
ENGINE
=
InnoDB
DEFAULT
CHARACTER
SET
=
utf8mb4
;
-- -----------------------------------------------------
-- Table `ilsexample`.`measurement`
-- -----------------------------------------------------
CREATE
TABLE
IF
NOT
EXISTS
ilsexample
.
`measurement`
(
`id`
INT
(
11
)
NOT
NULL
,
`name`
VARCHAR
(
45
)
NULL
DEFAULT
NULL
COMMENT
'监控参数标准名-英文'
,
`unit`
VARCHAR
(
45
)
NULL
DEFAULT
NULL
COMMENT
'单位'
,
`alias`
VARCHAR
(
45
)
NULL
DEFAULT
NULL
COMMENT
'其他名字'
,
PRIMARY
KEY
(
`id`
))
ENGINE
=
InnoDB
DEFAULT
CHARACTER
SET
=
utf8mb4
;
\ No newline at end of file
ils-service/src/main/resources/db
_migration/bootstrap
/bootstrap.sql
→
ils-service/src/main/resources/db
/old
/bootstrap.sql
浏览文件 @
3923b7e5
-- 该文件为不使用flyway之前的sql文件,仅作为一份留存文件,无实际意义。
-- MySQL Workbench Forward Engineering
-- MySQL Workbench Forward Engineering
SET
@
OLD_UNIQUE_CHECKS
=@@
UNIQUE_CHECKS
,
UNIQUE_CHECKS
=
0
;
SET
@
OLD_UNIQUE_CHECKS
=@@
UNIQUE_CHECKS
,
UNIQUE_CHECKS
=
0
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论