import { MigrationInterface, QueryRunner, Table, TableForeignKey, TableUnique } from 'typeorm'; export class CreateCustomStyles1686827869361 implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise { await queryRunner.createTable( new Table({ name: 'custom_styles', columns: [ { name: 'id', type: 'uuid', isGenerated: true, default: 'gen_random_uuid()', isPrimary: true, }, { name: 'organization_id', type: 'uuid', isNullable: true, }, { name: 'styles', type: 'varchar', isNullable: false, }, { name: 'scope', type: 'enum', enumName: 'custom_styles_scope_enum', enum: ['workspace', 'instance'], isNullable: false, default: `'workspace'`, }, { name: 'created_at', type: 'timestamp', isNullable: true, default: 'now()', }, { name: 'updated_at', type: 'timestamp', isNullable: true, default: 'now()', }, ], }), true ); await queryRunner.createForeignKey( 'custom_styles', new TableForeignKey({ columnNames: ['organization_id'], referencedColumnNames: ['id'], referencedTableName: 'organizations', onDelete: 'CASCADE', }) ); await queryRunner.createUniqueConstraint( 'custom_styles', new TableUnique({ name: 'custom_styles_organization_id_unique', columnNames: ['organization_id'], }) ); } public async down(queryRunner: QueryRunner): Promise { await queryRunner.dropTable('custom_styles'); } }