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.
63 lines
1.5 KiB
63 lines
1.5 KiB
import {Injectable, Migration, Inject, DatabaseService, FieldType} from '@extollo/lib'
|
|
|
|
/**
|
|
* CreateP5xNodesTableMigration
|
|
* ----------------------------------
|
|
* Create a table to track the virtual K8s containers under our control.
|
|
*/
|
|
@Injectable()
|
|
export default class CreateP5xNodesTableMigration 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_nodes')
|
|
|
|
table.primaryKey('id')
|
|
|
|
table.column('pve_id')
|
|
.type(FieldType.int)
|
|
.required()
|
|
|
|
table.column('hostname')
|
|
.type(FieldType.varchar)
|
|
.required()
|
|
|
|
table.column('assigned_ip')
|
|
.type(FieldType.varchar)
|
|
.required()
|
|
|
|
table.column('assigned_subnet')
|
|
.type(FieldType.int)
|
|
.required()
|
|
|
|
table.column('is_permanent')
|
|
.type(FieldType.bool)
|
|
.default(false)
|
|
.required()
|
|
|
|
table.column('is_master')
|
|
.type(FieldType.bool)
|
|
.default(false)
|
|
.required()
|
|
|
|
await schema.commit(table)
|
|
}
|
|
|
|
/**
|
|
* Undo the migration.
|
|
*/
|
|
async down(): Promise<void> {
|
|
const schema = this.db.get().schema()
|
|
const table = await schema.table('p5x_nodes')
|
|
|
|
table.dropIfExists()
|
|
|
|
await schema.commit(table)
|
|
}
|
|
}
|