From d9f53daeadf21bc049c755b364db679fbbfbae36 Mon Sep 17 00:00:00 2001 From: lvlin241 Date: Wed, 19 Jul 2023 10:51:36 +0800 Subject: [PATCH] [Optimize] create database automatically if it doesn't exist. --- .../db/migration/1.1.0/V1.1.0_0__DDL_datasophon.sql | 7 +++++-- .../db/migration/1.1.0/V1.1.0_1__DML_datasophon.sql | 2 ++ .../db/migration/1.1.1/V1.1.1_0__DDL_datasophon.sql | 1 + .../db/migration/1.1.1/V1.1.1_1__DML_datasophon.sql | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/datasophon-api/src/main/resources/db/migration/1.1.0/V1.1.0_0__DDL_datasophon.sql b/datasophon-api/src/main/resources/db/migration/1.1.0/V1.1.0_0__DDL_datasophon.sql index 17de45fa..991f80fd 100644 --- a/datasophon-api/src/main/resources/db/migration/1.1.0/V1.1.0_0__DDL_datasophon.sql +++ b/datasophon-api/src/main/resources/db/migration/1.1.0/V1.1.0_0__DDL_datasophon.sql @@ -15,8 +15,11 @@ * limitations under the License. */ - - +create database if not exists `datasophon` character set utf8 collate utf8_general_ci; +grant all privileges on *.* to datasophon@"%" identified by 'datasophon' with grant option; +GRANT ALL PRIVILEGES ON *.* TO 'datasophon'@'%'; +FLUSH PRIVILEGES; +use `datasophon`; SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; diff --git a/datasophon-api/src/main/resources/db/migration/1.1.0/V1.1.0_1__DML_datasophon.sql b/datasophon-api/src/main/resources/db/migration/1.1.0/V1.1.0_1__DML_datasophon.sql index 6fe5d744..e31cd4cf 100644 --- a/datasophon-api/src/main/resources/db/migration/1.1.0/V1.1.0_1__DML_datasophon.sql +++ b/datasophon-api/src/main/resources/db/migration/1.1.0/V1.1.0_1__DML_datasophon.sql @@ -15,6 +15,8 @@ * limitations under the License. */ +use `datasophon`; + -- ---------------------------- -- Records of t_ddh_access_token -- ---------------------------- diff --git a/datasophon-api/src/main/resources/db/migration/1.1.1/V1.1.1_0__DDL_datasophon.sql b/datasophon-api/src/main/resources/db/migration/1.1.1/V1.1.1_0__DDL_datasophon.sql index a634e5a4..b32c8171 100644 --- a/datasophon-api/src/main/resources/db/migration/1.1.1/V1.1.1_0__DDL_datasophon.sql +++ b/datasophon-api/src/main/resources/db/migration/1.1.1/V1.1.1_0__DDL_datasophon.sql @@ -1 +1,2 @@ +use `datasophon`; ALTER TABLE t_ddh_cluster_service_instance_role_group ADD need_restart INT(2); \ No newline at end of file diff --git a/datasophon-api/src/main/resources/db/migration/1.1.1/V1.1.1_1__DML_datasophon.sql b/datasophon-api/src/main/resources/db/migration/1.1.1/V1.1.1_1__DML_datasophon.sql index e69de29b..6cecb47c 100644 --- a/datasophon-api/src/main/resources/db/migration/1.1.1/V1.1.1_1__DML_datasophon.sql +++ b/datasophon-api/src/main/resources/db/migration/1.1.1/V1.1.1_1__DML_datasophon.sql @@ -0,0 +1 @@ +use `datasophon`; \ No newline at end of file