This repository has been archived on 2025-01-27. You can view files and clone it, but cannot push or open issues or pull requests.
puyoskey-rose/packages/backend/migration/1700456789000-UpdateIsIndexable.js
2024-08-01 23:39:36 +09:00

20 lines
931 B
JavaScript

export class Updatenoindex1700456789000 {
name = 'Updatenoindex1700456789000'
async up(queryRunner) {
// Rename column isindexable to noindex
await queryRunner.query(`ALTER TABLE "user" RENAME COLUMN "isIndexable" TO "noindex"`);
// Set default value of noindex to false
await queryRunner.query(`ALTER TABLE "user" ALTER COLUMN "noindex" SET DEFAULT false`);
// Optionally update all existing records if needed
await queryRunner.query(`UPDATE "user" SET "noindex" = NOT "noindex" WHERE "noindex" IS NULL`);
}
// async down(queryRunner) {
// await queryRunner.query(`UPDATE "user" SET "noindex" = NOT "noindex" WHERE "noindex" IS NULL`);
// await queryRunner.query(`ALTER TABLE "user" ALTER COLUMN "noindex" SET DEFAULT true`);
// await queryRunner.query(`ALTER TABLE "user" RENAME COLUMN "noindex" TO "isIndexable"`);
// }
}