From d95bb15beba13476351820c8deba5a076c0ae5db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B8=E9=A9=AC=E7=90=A6=E6=98=82?= Date: Sun, 27 Jul 2025 09:19:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20PostgreSQL=20JDBC?= =?UTF-8?q?=20URL=20=E9=85=8D=E7=BD=AE=E5=8F=8A=E9=83=A8=E5=88=86=20SQL=20?= =?UTF-8?q?=E8=AF=AD=E6=B3=95=E9=94=99=E8=AF=AF=20(#178)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/config/application-dev.yml | 2 +- .../src/main/resources/config/application-prod.yml | 2 +- .../src/main/resources/config/application-dev.yml | 2 +- .../src/main/resources/config/application-prod.yml | 2 +- .../db/changelog/postgresql/plugin/plugin_tenant.sql | 11 ++++------- 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/continew-extension/continew-extension-schedule-server/src/main/resources/config/application-dev.yml b/continew-extension/continew-extension-schedule-server/src/main/resources/config/application-dev.yml index abe86711..f95e8d75 100644 --- a/continew-extension/continew-extension-schedule-server/src/main/resources/config/application-dev.yml +++ b/continew-extension/continew-extension-schedule-server/src/main/resources/config/application-dev.yml @@ -8,7 +8,7 @@ spring.datasource: password: ${DB_PWD:123456} driver-class-name: com.mysql.cj.jdbc.Driver # # PostgreSQL 配置 -# url: jdbc:postgresql://${DB_HOST:127.0.0.1}:${DB_PORT:5432}/${DB_NAME:continew_admin_job}?serverTimezone=Asia/Shanghai&useSSL=true&useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&autoReconnect=true&stringtype=unspecified +# url: jdbc:postgresql://${DB_HOST:127.0.0.1}:${DB_PORT:5432}/${DB_NAME:continew_admin_job}?options=-c%20TimeZone=Asia/Shanghai&sslmode=prefer&channelBinding=require&stringtype=unspecified # username: ${DB_USER:root} # password: ${DB_PWD:123456} # driver-class-name: org.postgresql.Driver diff --git a/continew-extension/continew-extension-schedule-server/src/main/resources/config/application-prod.yml b/continew-extension/continew-extension-schedule-server/src/main/resources/config/application-prod.yml index d38197fe..ebc71cce 100644 --- a/continew-extension/continew-extension-schedule-server/src/main/resources/config/application-prod.yml +++ b/continew-extension/continew-extension-schedule-server/src/main/resources/config/application-prod.yml @@ -8,7 +8,7 @@ spring.datasource: password: ${DB_PWD:123456} driver-class-name: com.mysql.cj.jdbc.Driver # # PostgreSQL 配置 -# url: jdbc:postgresql://${DB_HOST:127.0.0.1}:${DB_PORT:5432}/${DB_NAME:continew_admin_job}?serverTimezone=Asia/Shanghai&useSSL=true&useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&autoReconnect=true&stringtype=unspecified +# url: jdbc:postgresql://${DB_HOST:127.0.0.1}:${DB_PORT:5432}/${DB_NAME:continew_admin_job}?options=-c%20TimeZone=Asia/Shanghai&sslmode=prefer&channelBinding=require&stringtype=unspecified # username: ${DB_USER:root} # password: ${DB_PWD:123456} # driver-class-name: org.postgresql.Driver diff --git a/continew-server/src/main/resources/config/application-dev.yml b/continew-server/src/main/resources/config/application-dev.yml index 3d109e52..23207f08 100644 --- a/continew-server/src/main/resources/config/application-dev.yml +++ b/continew-server/src/main/resources/config/application-dev.yml @@ -17,7 +17,7 @@ spring.datasource: password: ${DB_PWD:123456} driver-class-name: com.p6spy.engine.spy.P6SpyDriver # # PostgreSQL 配置 - # url: jdbc:p6spy:postgresql://${DB_HOST:127.0.0.1}:${DB_PORT:5432}/${DB_NAME:continew_admin}?serverTimezone=Asia/Shanghai&useSSL=true&useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&autoReconnect=true&stringtype=unspecified + # url: jdbc:p6spy:postgresql://${DB_HOST:127.0.0.1}:${DB_PORT:5432}/${DB_NAME:continew_admin}?options=-c%20TimeZone=Asia/Shanghai&sslmode=prefer&channelBinding=require&stringtype=unspecified # username: ${DB_USER:postgres} # password: ${DB_PWD:123456} # driver-class-name: com.p6spy.engine.spy.P6SpyDriver diff --git a/continew-server/src/main/resources/config/application-prod.yml b/continew-server/src/main/resources/config/application-prod.yml index 354bdeb5..195388e7 100644 --- a/continew-server/src/main/resources/config/application-prod.yml +++ b/continew-server/src/main/resources/config/application-prod.yml @@ -19,7 +19,7 @@ spring.datasource: password: ${DB_PWD:123456} driver-class-name: com.mysql.cj.jdbc.Driver # # PostgreSQL 配置 - # url: jdbc:postgresql://${DB_HOST:127.0.0.1}:${DB_PORT:5432}/${DB_NAME:continew_admin}?serverTimezone=Asia/Shanghai&useSSL=true&useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&autoReconnect=true&stringtype=unspecified + # url: jdbc:postgresql://${DB_HOST:127.0.0.1}:${DB_PORT:5432}/${DB_NAME:continew_admin}?options=-c%20TimeZone=Asia/Shanghai&sslmode=prefer&channelBinding=require&stringtype=unspecified # username: ${DB_USER:postgres} # password: ${DB_PWD:123456} # driver-class-name: org.postgresql.Driver diff --git a/continew-server/src/main/resources/db/changelog/postgresql/plugin/plugin_tenant.sql b/continew-server/src/main/resources/db/changelog/postgresql/plugin/plugin_tenant.sql index 8a593328..1b1bd26d 100644 --- a/continew-server/src/main/resources/db/changelog/postgresql/plugin/plugin_tenant.sql +++ b/continew-server/src/main/resources/db/changelog/postgresql/plugin/plugin_tenant.sql @@ -137,22 +137,19 @@ COMMENT ON COLUMN "sys_app"."tenant_id" IS '租户ID'; CREATE INDEX "idx_app_tenant_id" ON "sys_app" ("tenant_id"); -- 调整唯一索引 -ALTER TABLE "sys_dept" DROP INDEX "uk_dept_name_parent_id"; +DROP INDEX IF EXISTS "uk_dept_name_parent_id"; CREATE UNIQUE INDEX "uk_dept_name_parent_id" ON "sys_dept" ("name", "parent_id", "tenant_id"); -ALTER TABLE "sys_role" DROP INDEX "uk_role_name"; -ALTER TABLE "sys_role" DROP INDEX "uk_role_code"; +DROP INDEX IF EXISTS "uk_role_name", "uk_role_code"; CREATE UNIQUE INDEX "uk_role_name" ON "sys_role" ("name", "tenant_id"); CREATE UNIQUE INDEX "uk_role_code" ON "sys_role" ("code", "tenant_id"); -ALTER TABLE "sys_user" DROP INDEX "uk_user_username"; -ALTER TABLE "sys_user" DROP INDEX "uk_user_email"; -ALTER TABLE "sys_user" DROP INDEX "uk_user_phone"; +DROP INDEX IF EXISTS "uk_user_username", "uk_user_email", "uk_user_phone"; CREATE UNIQUE INDEX "uk_user_username" ON "sys_user" ("username", "tenant_id"); CREATE UNIQUE INDEX "uk_user_email" ON "sys_user" ("email", "tenant_id"); CREATE UNIQUE INDEX "uk_user_phone" ON "sys_user" ("phone", "tenant_id"); -ALTER TABLE "sys_app" DROP INDEX "uk_app_access_key"; +DROP INDEX IF EXISTS "uk_app_access_key"; CREATE UNIQUE INDEX "uk_app_access_key" ON "sys_app" ("access_key", "tenant_id"); -- 初始化默认菜单