增加了 flyway 进行数据初始化
diff --git a/src/main/kotlin/com/supwisdom/dlpay/migration.kt b/src/main/kotlin/com/supwisdom/dlpay/migration.kt
new file mode 100644
index 0000000..5495bca
--- /dev/null
+++ b/src/main/kotlin/com/supwisdom/dlpay/migration.kt
@@ -0,0 +1,32 @@
+package com.supwisdom.dlpay
+
+import org.springframework.boot.autoconfigure.flyway.FlywayMigrationInitializer
+import org.flywaydb.core.Flyway
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Configuration
+import org.springframework.context.annotation.DependsOn
+
+
+@Configuration
+class MigrationConfiguration {
+
+ /**
+ * Override default flyway initializer to do nothing
+ */
+ @Bean
+ fun flywayInitializer(flyway: Flyway): FlywayMigrationInitializer {
+ return FlywayMigrationInitializer(flyway) { f -> }
+ }
+
+
+ /**
+ * Create a second flyway initializer to run after jpa has created the schema
+ */
+ @Bean
+ @DependsOn("entityManagerFactory")
+ fun delayedFlywayInitializer(flyway: Flyway): FlywayMigrationInitializer {
+ return FlywayMigrationInitializer(flyway, null)
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index afe6400..db534ba 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -3,11 +3,11 @@
spring.jpa.show-sql=true
spring.datasource.hikari.connection-timeout=60000
spring.datasource.hikari.maximum-pool-size=5
-spring.datasource.initialization-mode=always
-spring.datasource.continue-on-error=true
spring.jpa.hibernate.ddl-auto=update
spring.flyway.locations=classpath:db/migration
+spring.flyway.baseline-version=0
+spring.flyway.baseline-on-migrate=true
# logging
logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n
logging.level.org.hibernate.SQL=debug
diff --git a/src/main/resources/db/migration/V1_0-init_data.sql b/src/main/resources/db/migration/V1.0__init_data.sql
similarity index 63%
rename from src/main/resources/db/migration/V1_0-init_data.sql
rename to src/main/resources/db/migration/V1.0__init_data.sql
index 0b14207..a28028b 100644
--- a/src/main/resources/db/migration/V1_0-init_data.sql
+++ b/src/main/resources/db/migration/V1.0__init_data.sql
@@ -5,18 +5,18 @@
VALUES ('LOR2IwRkbOjp+sVG9KR2BpHZbwGKepS4', '20500101', '20190101', 'system', '系统管理员', '$2a$10$Ex9xp11.vCaD8D0a7ahiUOKqDij1TcCUBwRAmrqXeDvAkmzLibn4.', '', 'normal');
INSERT INTO tb_role(
- role_id, createtime, editflag, lastsaved, rolecode, roledesc, rolename)
+ roleid, createtime, editflag, lastsaved, rolecode, roledesc, rolename)
VALUES ('d1yctWs5+ks0iQN3m9bUvRHus6HbKbrs', '20190101000000', 0, '', 'ROLE_ADMIN', '超级管理员', '超级管理员');
INSERT INTO tb_oper_role(
- id, operid, role_id)
+ id, operid, roleid)
VALUES ('1', 'LOR2IwRkbOjp+sVG9KR2BpHZbwGKepS4', 'd1yctWs5+ks0iQN3m9bUvRHus6HbKbrs');
-- 功能表
-Insert into TB_FUNCTION (ID,PARENT_ID,NAME,ORDER_NUM,MENU_URL,MENU_ICON,IS_LEAF)
+Insert into TB_FUNCTION (ID,PARENTID,NAME,ORDERNUM,MENUURL,MENUICON,ISLEAF)
values ('1','-1','系统中心',1,'#','layui-icon-set',0);
-Insert into TB_FUNCTION (ID,PARENT_ID,NAME,ORDER_NUM,MENU_URL,MENU_ICON,IS_LEAF)
+Insert into TB_FUNCTION (ID,PARENTID,NAME,ORDERNUM,MENUURL,MENUICON,ISLEAF)
values ('2','1','管理员维护',1,'#','layui-icon-set',1);
-Insert into TB_ROLE_FUNCTION (ID,FUNCTION_ID,ROLE_ID) values ('1','1','d1yctWs5+ks0iQN3m9bUvRHus6HbKbrs');
-Insert into TB_ROLE_FUNCTION (ID,FUNCTION_ID,ROLE_ID) values ('2','2','d1yctWs5+ks0iQN3m9bUvRHus6HbKbrs');
\ No newline at end of file
+Insert into TB_ROLE_FUNCTION (ID,FUNCTIONID,ROLEID) values ('1','1','d1yctWs5+ks0iQN3m9bUvRHus6HbKbrs');
+Insert into TB_ROLE_FUNCTION (ID,FUNCTIONID,ROLEID) values ('2','2','d1yctWs5+ks0iQN3m9bUvRHus6HbKbrs');
\ No newline at end of file