refactor: fix lucid warning

This commit is contained in:
Sonny
2024-10-07 02:24:27 +02:00
parent c8fb5af44d
commit 8b4e5740d7
3 changed files with 45 additions and 28 deletions

View File

@@ -5,7 +5,13 @@ export default class CreateLinksTable extends BaseSchema {
static tableName = 'links';
async up() {
this.schema.createTableIfNotExists(CreateLinksTable.tableName, (table) => {
const exists = await this.schema.hasTable(CreateLinksTable.tableName);
if (exists) {
return console.warn(`Table ${CreateLinksTable.tableName} already
exists.`);
}
this.schema.createTable(CreateLinksTable.tableName, (table) => {
table.string('name', 254).notNullable();
table.string('description', 254).nullable();
table.text('url').notNullable();