mirror of
https://github.com/sergeyyarkov/educt-server.git
synced 2026-10-11 10:19:20 +03:00
26 lines
657 B
TypeScript
26 lines
657 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: true,
|
|
schemaName: 'public',
|
|
})
|
|
.notNullable();
|
|
table.string('hex').notNullable();
|
|
});
|
|
}
|
|
|
|
public async down() {
|
|
this.schema.dropTable(this.tableName);
|
|
}
|
|
}
|