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.
45 lines
947 B
45 lines
947 B
import {Template} from '../../cli'
|
|
|
|
/**
|
|
* Template for creating new migration classes in app/migrations.
|
|
*/
|
|
const templateMigration: Template = {
|
|
name: 'migration',
|
|
fileSuffix: '.migration.ts',
|
|
baseAppPath: ['migrations'],
|
|
description: 'Create a new class that applies a one-time migration',
|
|
render: (name: string) => {
|
|
return `import {Injectable, Migration, Inject, DatabaseService} from '@extollo/lib'
|
|
|
|
/**
|
|
* ${name}
|
|
* ----------------------------------
|
|
* Put some description here.
|
|
*/
|
|
@Injectable()
|
|
export default class ${name} extends Migration {
|
|
@Inject()
|
|
protected readonly db!: DatabaseService
|
|
|
|
/**
|
|
* Apply the migration.
|
|
*/
|
|
async up(): Promise<void> {
|
|
const schema = this.db.get().schema()
|
|
|
|
}
|
|
|
|
/**
|
|
* Undo the migration.
|
|
*/
|
|
async down(): Promise<void> {
|
|
const schema = this.db.get().schema()
|
|
|
|
}
|
|
}
|
|
`
|
|
},
|
|
}
|
|
|
|
export { templateMigration }
|