Fix category migration
1 files changed, 5 insertions, 1 deletions
diff --git a/src/database/migration/postgres/1786139482251-Int2CategoryId.ts b/src/database/migration/postgres/1786139482251-Int2CategoryId.ts
index fa94fd44..58dd89ef 100644
--- a/src/database/migration/postgres/1786139482251-Int2CategoryId.ts
+++ b/src/database/migration/postgres/1786139482251-Int2CategoryId.ts
@@ -5,7 +5,11 @@ export class Int2CategoryId1786139482251 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE guilds ALTER COLUMN primary_category_id TYPE int2 USING primary_category_id::int2`);
- await queryRunner.query(`ALTER TABLE categories ALTER COLUMN id TYPE smallserial USING id::smallserial`);
+ await queryRunner.query(`CREATE SEQUENCE categories_id_seq AS int2`);
+ await queryRunner.query(`ALTER TABLE categories ALTER COLUMN id TYPE int2 USING id::int2`);
+ await queryRunner.query(`ALTER TABLE categories ALTER COLUMN id SET NOT NULL`);
+ await queryRunner.query(`ALTER TABLE categories ALTER COLUMN id SET DEFAULT nextval('categories_id_seq')`);
+ await queryRunner.query(`ALTER SEQUENCE categories_id_seq OWNED BY categories.id`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
|