import Migration from "swaf/db/Migration"; import ModelFactory from "swaf/db/ModelFactory"; import URLRedirect from "../models/URLRedirect.js"; export default class CreateUrlRedirectsTable extends Migration { public async install(): Promise { await this.query(`CREATE TABLE url_redirects ( id INT NOT NULL AUTO_INCREMENT, user_id INT NOT NULL, slug VARCHAR(259) UNIQUE NOT NULL, target_url VARCHAR(1745) NOT NULL, created_at DATETIME NOT NULL DEFAULT NOW(), PRIMARY KEY (id) )`); } public async rollback(): Promise { await this.query(`DROP TABLE IF EXISTS url_redirects`); } public registerModels(): void { ModelFactory.register(URLRedirect); } }