31 lines
1.3 KiB
TypeScript
31 lines
1.3 KiB
TypeScript
import Migration from "swaf/db/Migration";
|
|
import ModelFactory from "swaf/db/ModelFactory";
|
|
|
|
import FileModel from "../models/FileModel.js";
|
|
|
|
export default class CreateFilesTable extends Migration {
|
|
public async install(): Promise<void> {
|
|
await this.query(`CREATE TABLE files
|
|
(
|
|
id INT NOT NULL AUTO_INCREMENT,
|
|
user_id INT NOT NULL,
|
|
slug VARCHAR(259) UNIQUE NOT NULL,
|
|
real_name VARCHAR(259) NOT NULL,
|
|
storage_type VARCHAR(64) NOT NULL,
|
|
storage_path VARCHAR(1745) NOT NULL,
|
|
size INT UNSIGNED NOT NULL,
|
|
created_at DATETIME NOT NULL DEFAULT NOW(),
|
|
ttl INT UNSIGNED NOT NULL,
|
|
PRIMARY KEY (id)
|
|
)`);
|
|
}
|
|
|
|
public async rollback(): Promise<void> {
|
|
await this.query(`DROP TABLE IF EXISTS files`);
|
|
}
|
|
|
|
public registerModels(): void {
|
|
ModelFactory.register(FileModel);
|
|
}
|
|
}
|