You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.3 KiB
57 lines
1.3 KiB
import {Injectable, Migration, Inject, DatabaseService, FieldType} from '@extollo/lib'
|
|
|
|
/**
|
|
* CreateP5xIpRangesTableMigration
|
|
* ----------------------------------
|
|
* Put some description here.
|
|
*/
|
|
@Injectable()
|
|
export default class CreateP5xIpRangesTableMigration extends Migration {
|
|
@Inject()
|
|
protected readonly db!: DatabaseService
|
|
|
|
/**
|
|
* Apply the migration.
|
|
*/
|
|
async up(): Promise<void> {
|
|
const schema = this.db.get().schema()
|
|
const table = await schema.table('p5x_ip_ranges')
|
|
|
|
table.primaryKey('id')
|
|
|
|
table.column('name')
|
|
.type(FieldType.varchar)
|
|
.required()
|
|
|
|
table.column('start_ip')
|
|
.type(FieldType.varchar)
|
|
.required()
|
|
|
|
table.column('end_ip')
|
|
.type(FieldType.varchar)
|
|
.required()
|
|
|
|
table.column('subnet')
|
|
.type(FieldType.int)
|
|
.required()
|
|
|
|
table.column('gateway_ip')
|
|
.type(FieldType.varchar)
|
|
.required()
|
|
|
|
await schema.commit(table)
|
|
}
|
|
|
|
/**
|
|
* Undo the migration.
|
|
*/
|
|
async down(): Promise<void> {
|
|
const schema = this.db.get().schema()
|
|
const table = await schema.table('p5x_ip_ranges')
|
|
|
|
table.dropIfExists()
|
|
|
|
await schema.commit(table)
|
|
}
|
|
}
|