2021-05-03 19:29:22 +02:00
|
|
|
import Migration from "../../db/Migration.js";
|
|
|
|
import ModelFactory from "../../db/ModelFactory.js";
|
|
|
|
import User from "../models/User.js";
|
|
|
|
import UserPasswordComponent from "./UserPasswordComponent.js";
|
2020-11-11 19:08:33 +01:00
|
|
|
|
|
|
|
export default class AddPasswordToUsersMigration extends Migration {
|
|
|
|
public async install(): Promise<void> {
|
|
|
|
await this.query(`ALTER TABLE users
|
2020-11-14 17:24:42 +01:00
|
|
|
ADD COLUMN password VARCHAR(128) DEFAULT NULL`);
|
2020-11-11 19:08:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public async rollback(): Promise<void> {
|
|
|
|
await this.query(`ALTER TABLE users
|
|
|
|
DROP COLUMN password`);
|
|
|
|
}
|
|
|
|
|
|
|
|
public registerModels(): void {
|
|
|
|
ModelFactory.get(User).addComponent(UserPasswordComponent);
|
|
|
|
}
|
|
|
|
}
|