change user model to login routine
This commit is contained in:
parent
c35b99e0c4
commit
03a5bb3592
5 changed files with 56 additions and 3 deletions
32
src/migrations/1746252454922-UserLoginRoutine.ts
Normal file
32
src/migrations/1746252454922-UserLoginRoutine.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import { MigrationInterface, QueryRunner, TableColumn } from "typeorm";
|
||||
import { getDefaultByORM, getTypeByORM } from "./ormHelper";
|
||||
|
||||
export class UserLoginRoutine1746252454922 implements MigrationInterface {
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
let users = await queryRunner.manager.getRepository("user").find({ select: ["id", "secret"] });
|
||||
|
||||
await queryRunner.dropColumns("user", ["secret", "static"]);
|
||||
|
||||
await queryRunner.addColumns("user", [
|
||||
new TableColumn({ name: "secret", ...getTypeByORM("text") }),
|
||||
new TableColumn({ name: "routine", ...getTypeByORM("varchar") }),
|
||||
]);
|
||||
|
||||
await queryRunner.manager.getRepository("user").save(users.map((u) => ({ id: u.id, secret: u.secret })));
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
let users = await queryRunner.manager.getRepository("user").find({ select: ["id", "secret"] });
|
||||
|
||||
await queryRunner.dropColumn("user", "secret");
|
||||
|
||||
await queryRunner.addColumns("user", [
|
||||
new TableColumn({ name: "secret", ...getTypeByORM("varchar") }),
|
||||
new TableColumn({ name: "static", ...getTypeByORM("boolean"), default: getDefaultByORM("boolean", false) }),
|
||||
]);
|
||||
|
||||
await queryRunner.manager.getRepository("user").save(users.map((u) => ({ id: u.id, secret: u.secret })));
|
||||
|
||||
await queryRunner.dropColumn("user", "routine");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue