This commit is contained in:
2026-06-28 22:43:08 +03:30
parent 322c9018da
commit 127c1eaf78
14 changed files with 500 additions and 0 deletions
@@ -0,0 +1,64 @@
import { MigrationInterface, QueryRunner, Table, TableForeignKey } from 'typeorm';
export class AddServices1719800000000 implements MigrationInterface {
name = 'AddServices1719800000000';
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.createTable(
new Table({
name: 'services',
columns: [
{
name: 'id',
type: 'uuid',
isPrimary: true,
generationStrategy: 'uuid',
default: 'gen_random_uuid()',
},
{ name: 'title', type: 'varchar', length: '200' },
{ name: 'iconUrl', type: 'varchar', length: '500', isNullable: true },
{ name: 'coverUrl', type: 'varchar', length: '500', isNullable: true },
{ name: 'createdAt', type: 'timestamp', default: 'now()' },
{ name: 'updatedAt', type: 'timestamp', default: 'now()' },
],
}),
true,
);
await queryRunner.createTable(
new Table({
name: 'service_skills',
columns: [
{
name: 'id',
type: 'uuid',
isPrimary: true,
generationStrategy: 'uuid',
default: 'gen_random_uuid()',
},
{ name: 'serviceId', type: 'uuid' },
{ name: 'title', type: 'varchar', length: '200' },
{ name: 'renewalDays', type: 'int' },
{ name: 'createdAt', type: 'timestamp', default: 'now()' },
{ name: 'updatedAt', type: 'timestamp', default: 'now()' },
],
}),
true,
);
await queryRunner.createForeignKey(
'service_skills',
new TableForeignKey({
columnNames: ['serviceId'],
referencedTableName: 'services',
referencedColumnNames: ['id'],
onDelete: 'CASCADE',
}),
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropTable('service_skills', true);
await queryRunner.dropTable('services', true);
}
}