From beb46b2b3b4bec5c0be205f90e10a85ce4f471ff Mon Sep 17 00:00:00 2001
From: Dapeng <verydapeng@gmail.com>
Date: Mon, 27 Jun 2016 12:35:37 +0800
Subject: [PATCH] support switching db init script at deployment

---
 src/main/resources/application.properties     | 23 ++++++++-----------
 .../db/hsqldb/{populateDB.sql => data.sql}    |  0
 .../db/hsqldb/{initDB.sql => schema.sql}      |  0
 .../db/mysql/{populateDB.sql => data.sql}     |  0
 .../db/mysql/{initDB.sql => schema.sql}       |  0
 5 files changed, 10 insertions(+), 13 deletions(-)
 rename src/main/resources/db/hsqldb/{populateDB.sql => data.sql} (100%)
 rename src/main/resources/db/hsqldb/{initDB.sql => schema.sql} (100%)
 rename src/main/resources/db/mysql/{populateDB.sql => data.sql} (100%)
 rename src/main/resources/db/mysql/{initDB.sql => schema.sql} (100%)

diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 81832a6..db5befa 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1,23 +1,20 @@
-# Web
-spring.mvc.view.prefix: /WEB-INF/jsp/
-spring.mvc.view.suffix: .jsp
+# database init, supports mysql too
+database=hsqldb
+spring.datasource.schema=classpath*:db/${database}/schema.sql
+spring.datasource.data=classpath*:db/${database}/data.sql
 
+# Web
+spring.mvc.view.prefix=/WEB-INF/jsp/
+spring.mvc.view.suffix=.jsp
 
 # JPA
-spring.jpa.hibernate.ddl-auto: none
-#spring.jpa.database: HSQL
-#spring.jpa.show-sql: true
-#spring.datasource.driverClassName=org.hsqldb.jdbcDriver
-spring.datasource.schema: classpath*:db/hsqldb/initDB.sql
-spring.datasource.data: classpath*:db/hsqldb/populateDB.sql
-#spring.datasource.username: sa
-#spring.datasource.password:
+spring.jpa.hibernate.ddl-auto=none
 
 # Internationalization
-spring.messages.basename: messages/messages
+spring.messages.basename=messages/messages
 
 # Actuator / Management
-management.contextPath: /manage
+management.contextPath=/manage
 
 # Logging
 logging.level.org.springframework=INFO
diff --git a/src/main/resources/db/hsqldb/populateDB.sql b/src/main/resources/db/hsqldb/data.sql
similarity index 100%
rename from src/main/resources/db/hsqldb/populateDB.sql
rename to src/main/resources/db/hsqldb/data.sql
diff --git a/src/main/resources/db/hsqldb/initDB.sql b/src/main/resources/db/hsqldb/schema.sql
similarity index 100%
rename from src/main/resources/db/hsqldb/initDB.sql
rename to src/main/resources/db/hsqldb/schema.sql
diff --git a/src/main/resources/db/mysql/populateDB.sql b/src/main/resources/db/mysql/data.sql
similarity index 100%
rename from src/main/resources/db/mysql/populateDB.sql
rename to src/main/resources/db/mysql/data.sql
diff --git a/src/main/resources/db/mysql/initDB.sql b/src/main/resources/db/mysql/schema.sql
similarity index 100%
rename from src/main/resources/db/mysql/initDB.sql
rename to src/main/resources/db/mysql/schema.sql
-- 
GitLab