Skip to content

Commit

Permalink
filename migration
Browse files Browse the repository at this point in the history
  • Loading branch information
siiptuo committed Nov 27, 2024
1 parent bf68fdb commit a4690a5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions backend/src/migration/1730123930898-AddFilenameColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ export class AddFilenameColumn1730123930898 implements MigrationInterface {

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "regular_file" ADD "filename" character varying`);
await queryRunner.query(`UPDATE "regular_file" SET "filename" = regexp_replace(s3key, '.+/', '')`);
await queryRunner.query(`ALTER TABLE "regular_file" ALTER COLUMN "filename" SET NOT NULL;`);
await queryRunner.query(`ALTER TABLE "model_file" ADD "filename" character varying`);
await queryRunner.query(`UPDATE "model_file" SET "filename" = regexp_replace(s3key, '.+/', '')`);
await queryRunner.query(`ALTER TABLE "model_file" ALTER COLUMN "filename" SET NOT NULL;`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
Expand Down

0 comments on commit a4690a5

Please sign in to comment.