mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-08 22:53:25 +00:00
refactor: use tabs instead of spaces
This commit is contained in:
@@ -3,42 +3,42 @@ import { Visibility } from '#enums/visibility';
|
||||
import { BaseSchema } from '@adonisjs/lucid/schema';
|
||||
|
||||
export default class CreateCollectionTable extends BaseSchema {
|
||||
static tableName = 'collections';
|
||||
private visibilityEnumName = 'collection_visibility';
|
||||
static tableName = 'collections';
|
||||
private visibilityEnumName = 'collection_visibility';
|
||||
|
||||
async up() {
|
||||
this.schema.raw(`DROP TYPE IF EXISTS ${this.visibilityEnumName}`);
|
||||
this.schema.createTableIfNotExists(
|
||||
CreateCollectionTable.tableName,
|
||||
(table) => {
|
||||
table.string('name', 254).notNullable();
|
||||
table.string('description', 254).nullable();
|
||||
table
|
||||
.enum('visibility', Object.values(Visibility), {
|
||||
useNative: true,
|
||||
enumName: this.visibilityEnumName,
|
||||
existingType: false,
|
||||
})
|
||||
.nullable()
|
||||
.defaultTo(Visibility.PRIVATE);
|
||||
table
|
||||
.integer('next_id')
|
||||
.references('id')
|
||||
.inTable('collections')
|
||||
.defaultTo(null);
|
||||
table
|
||||
.integer('author_id')
|
||||
.references('id')
|
||||
.inTable('users')
|
||||
.onDelete('CASCADE');
|
||||
async up() {
|
||||
this.schema.raw(`DROP TYPE IF EXISTS ${this.visibilityEnumName}`);
|
||||
this.schema.createTableIfNotExists(
|
||||
CreateCollectionTable.tableName,
|
||||
(table) => {
|
||||
table.string('name', 254).notNullable();
|
||||
table.string('description', 254).nullable();
|
||||
table
|
||||
.enum('visibility', Object.values(Visibility), {
|
||||
useNative: true,
|
||||
enumName: this.visibilityEnumName,
|
||||
existingType: false,
|
||||
})
|
||||
.nullable()
|
||||
.defaultTo(Visibility.PRIVATE);
|
||||
table
|
||||
.integer('next_id')
|
||||
.references('id')
|
||||
.inTable('collections')
|
||||
.defaultTo(null);
|
||||
table
|
||||
.integer('author_id')
|
||||
.references('id')
|
||||
.inTable('users')
|
||||
.onDelete('CASCADE');
|
||||
|
||||
defaultTableFields(table);
|
||||
}
|
||||
);
|
||||
}
|
||||
defaultTableFields(table);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async down() {
|
||||
this.schema.raw(`DROP TYPE IF EXISTS ${this.visibilityEnumName}`);
|
||||
this.schema.dropTable(CreateCollectionTable.tableName);
|
||||
}
|
||||
async down() {
|
||||
this.schema.raw(`DROP TYPE IF EXISTS ${this.visibilityEnumName}`);
|
||||
this.schema.dropTable(CreateCollectionTable.tableName);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user