data-source.ts 556 B

123456789101112131415161718
  1. import "reflect-metadata"
  2. import { DataSource } from "typeorm"
  3. import { User } from "./modules/users/user.entity"
  4. import { Role } from "./modules/users/role.entity";
  5. import { CreateUserTables } from "./migrations/001-CreateUserTables";
  6. export const AppDataSource = new DataSource({
  7. type: "mysql",
  8. host: "localhost", // 使用IP地址而非localhost
  9. port: 3306,
  10. username: "root",
  11. password: "", // 请替换为实际密码
  12. database: "test",
  13. entities: [ User, Role],
  14. migrations: [CreateUserTables],
  15. synchronize: true,
  16. logging: true
  17. });