master
parent
d4d10af972
commit
a6e1819d2d
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,13 @@
|
||||
import {Unit, Singleton, MigrateDirective} from '@extollo/lib'
|
||||
|
||||
/**
|
||||
* Apply migrations when the application starts up.
|
||||
* This is way more convenient than `./ex migrate` for Kubernetes deployments.
|
||||
*/
|
||||
@Singleton()
|
||||
export class MigrateUnit extends Unit {
|
||||
async up() {
|
||||
const directive = this.make<MigrateDirective>(MigrateDirective)
|
||||
await directive.invoke([])
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
import {Injectable, Migration, Inject, DatabaseService, FieldType} from '@extollo/lib'
|
||||
|
||||
/**
|
||||
* AddCoreidColumnsToUsersTableMigration
|
||||
* ----------------------------------
|
||||
* Put some description here.
|
||||
*/
|
||||
@Injectable()
|
||||
export default class AddCoreidColumnsToUsersTableMigration 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('users')
|
||||
|
||||
table.column('tagline')
|
||||
.type(FieldType.varchar)
|
||||
.nullable()
|
||||
|
||||
table.column('photo_url')
|
||||
.type(FieldType.varchar)
|
||||
.nullable()
|
||||
|
||||
await schema.commit(table)
|
||||
}
|
||||
|
||||
/**
|
||||
* Undo the migration.
|
||||
*/
|
||||
async down(): Promise<void> {
|
||||
const schema = this.db.get().schema()
|
||||
const table = await schema.table('users')
|
||||
|
||||
table.dropColumn('tagline')
|
||||
table.dropColumn('photo_url')
|
||||
|
||||
await schema.commit(table)
|
||||
}
|
||||
}
|
Loading…
Reference in new issue