Files
grow-api/src/database/migrations/1720100000000-AddSmsTemplates.ts
T
2026-07-08 22:23:14 +03:30

41 lines
1.2 KiB
TypeScript

import { MigrationInterface, QueryRunner, Table, TableIndex } from 'typeorm';
export class AddSmsTemplates1720100000000 implements MigrationInterface {
name = 'AddSmsTemplates1720100000000';
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.createTable(
new Table({
name: 'sms_templates',
columns: [
{
name: 'id',
type: 'uuid',
isPrimary: true,
generationStrategy: 'uuid',
default: 'gen_random_uuid()',
},
{ name: 'title', type: 'varchar', length: '200' },
{ name: 'body', type: 'text' },
{ name: 'isActive', type: 'boolean', default: true },
{ name: 'createdAt', type: 'timestamp', default: 'now()' },
{ name: 'updatedAt', type: 'timestamp', default: 'now()' },
],
}),
true,
);
await queryRunner.createIndex(
'sms_templates',
new TableIndex({
name: 'IDX_sms_templates_isActive',
columnNames: ['isActive'],
}),
);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropTable('sms_templates', true);
}
}