Browse Source

🔧 chore(database): switch database type from mysql to postgres

- update test database url from mysql to postgresql format
- change database type from "mysql" to "postgres" for both test and production environments
- update default port from 3306 to 5432
- change default username from "root" to "postgres"
- update default database name from "d8dai" to "postgres"
yourname 1 month ago
parent
commit
72b3ed817f
1 changed files with 6 additions and 6 deletions
  1. 6 6
      src/server/data-source.ts

+ 6 - 6
src/server/data-source.ts

@@ -17,11 +17,11 @@ import { ConsultationRequest } from "./modules/consultation/consultation-request
 
 // 在测试环境下使用测试数据库配置
 const isTestEnv = process.env.NODE_ENV === 'test';
-const testDatabaseUrl = process.env.TEST_DATABASE_URL || 'mysql://root:test_password@localhost:3306/test_d8dai';
+const testDatabaseUrl = process.env.TEST_DATABASE_URL || 'postgresql://postgres:test_password@localhost:5432/test_d8dai';
 
 const dataSource = isTestEnv && testDatabaseUrl
   ? new DataSource({
-      type: "mysql",
+      type: "postgres",
       url: testDatabaseUrl,
       entities: [
         User, Role, File, PaymentEntity, MembershipPlan, Template, SystemSetting,
@@ -35,12 +35,12 @@ const dataSource = isTestEnv && testDatabaseUrl
       logging: false,    // 测试环境关闭日志
     })
   : new DataSource({
-      type: "mysql",
+      type: "postgres",
       host: process.env.DB_HOST || "localhost",
-  port: parseInt(process.env.DB_PORT || "3306"),
-  username: process.env.DB_USERNAME || "root",
+  port: parseInt(process.env.DB_PORT || "5432"),
+  username: process.env.DB_USERNAME || "postgres",
       password: process.env.DB_PASSWORD || "",
-  database: process.env.DB_DATABASE || "d8dai",
+  database: process.env.DB_DATABASE || "postgres",
       entities: [
         User, Role, File, PaymentEntity, MembershipPlan, Template, SystemSetting,
         SolutionDesign, SolutionChapter, ConsultationRequest,