mirror of
https://github.com/sergeyyarkov/educt-server.git
synced 2026-10-11 02:09:07 +03:00
27 lines
734 B
TypeScript
27 lines
734 B
TypeScript
import BaseSchema from '@ioc:Adonis/Lucid/Schema';
|
|
import ColorEnum from 'App/Datatypes/Enums/ColorEnum';
|
|
|
|
export default class Colors extends BaseSchema {
|
|
protected tableName = 'colors';
|
|
|
|
public async up() {
|
|
this.schema.createTable(this.tableName, table => {
|
|
table.increments('id').primary();
|
|
table
|
|
.enu('name', Object.keys(ColorEnum), {
|
|
useNative: true,
|
|
enumName: 'color_name_enum',
|
|
existingType: false,
|
|
schemaName: 'public',
|
|
})
|
|
.notNullable();
|
|
table.string('hex').notNullable();
|
|
});
|
|
}
|
|
|
|
public async down() {
|
|
await this.schema.raw('DROP TYPE IF EXISTS "color_name_enum" CASCADE');
|
|
this.schema.dropTable(this.tableName);
|
|
}
|
|
}
|