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.
www/src/app/migrations/2023-11-07T04:03:41.732Z_Cr...

53 lines
1.2 KiB

import {Injectable, Migration, Inject, DatabaseService, FieldType} from '@extollo/lib'
/**
* CreatePubCertificatesTableMigration
* ----------------------------------
* Put some description here.
*/
@Injectable()
export default class CreatePubCertificatesTableMigration 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('pub_certificates')
table.primaryKey('certificate_id')
table.column('reltype')
.type(FieldType.varchar)
table.column('relid')
.type(FieldType.bigint)
table.column('pubkey')
.type(FieldType.text)
table.column('privkey')
.type(FieldType.text)
table.index('pub_cert_rel')
.field('reltype')
.field('relid')
await schema.commit(table)
}
/**
* Undo the migration.
*/
async down(): Promise<void> {
const schema = this.db.get().schema()
const table = await schema.table('pub_certificates')
table.dropIfExists()
await schema.commit(table)
}
}