This commit is contained in:
@ -21,7 +21,9 @@ import { IdeasModule } from './ideas/ideas.module';
|
||||
password: configService.get('DB_PASSWORD', 'teamplanner'),
|
||||
database: configService.get('DB_DATABASE', 'teamplanner'),
|
||||
entities: [__dirname + '/**/*.entity{.ts,.js}'],
|
||||
synchronize: true, // Only for development!
|
||||
migrations: [__dirname + '/migrations/*{.ts,.js}'],
|
||||
migrationsRun: true,
|
||||
synchronize: false,
|
||||
}),
|
||||
}),
|
||||
IdeasModule,
|
||||
|
||||
16
backend/src/data-source.ts
Normal file
16
backend/src/data-source.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { DataSource } from 'typeorm';
|
||||
import { config } from 'dotenv';
|
||||
|
||||
config();
|
||||
|
||||
export const AppDataSource = new DataSource({
|
||||
type: 'postgres',
|
||||
host: process.env.DB_HOST ?? 'localhost',
|
||||
port: parseInt(process.env.DB_PORT ?? '5432', 10),
|
||||
username: process.env.DB_USERNAME ?? 'teamplanner',
|
||||
password: process.env.DB_PASSWORD ?? 'teamplanner',
|
||||
database: process.env.DB_DATABASE ?? 'teamplanner',
|
||||
entities: [__dirname + '/**/*.entity{.ts,.js}'],
|
||||
migrations: [__dirname + '/migrations/*{.ts,.js}'],
|
||||
synchronize: false,
|
||||
});
|
||||
39
backend/src/migrations/1735660800000-InitialMigration.ts
Normal file
39
backend/src/migrations/1735660800000-InitialMigration.ts
Normal file
@ -0,0 +1,39 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class InitialMigration1735660800000 implements MigrationInterface {
|
||||
name = 'InitialMigration1735660800000';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`CREATE TYPE "public"."ideas_status_enum" AS ENUM('backlog', 'todo', 'in_progress', 'done', 'cancelled')`,
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TYPE "public"."ideas_priority_enum" AS ENUM('low', 'medium', 'high', 'critical')`,
|
||||
);
|
||||
await queryRunner.query(`
|
||||
CREATE TABLE "ideas" (
|
||||
"id" uuid NOT NULL DEFAULT uuid_generate_v4(),
|
||||
"title" character varying NOT NULL,
|
||||
"description" text,
|
||||
"status" "public"."ideas_status_enum" NOT NULL DEFAULT 'backlog',
|
||||
"priority" "public"."ideas_priority_enum" NOT NULL DEFAULT 'medium',
|
||||
"module" character varying(100),
|
||||
"target_audience" character varying(255),
|
||||
"pain" text,
|
||||
"ai_role" text,
|
||||
"verification_method" text,
|
||||
"color" character varying(20),
|
||||
"order" integer NOT NULL DEFAULT '0',
|
||||
"created_at" TIMESTAMP NOT NULL DEFAULT now(),
|
||||
"updated_at" TIMESTAMP NOT NULL DEFAULT now(),
|
||||
CONSTRAINT "PK_ideas_id" PRIMARY KEY ("id")
|
||||
)
|
||||
`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`DROP TABLE "ideas"`);
|
||||
await queryRunner.query(`DROP TYPE "public"."ideas_priority_enum"`);
|
||||
await queryRunner.query(`DROP TYPE "public"."ideas_status_enum"`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user