parent
814a5763d9
commit
fd77ad5cd3
@ -0,0 +1,46 @@
|
|||||||
|
import {DatabaseService, FieldType, Migration, raw, Schema} from '../orm'
|
||||||
|
import {Inject} from '../di'
|
||||||
|
|
||||||
|
export default class CreateOAuth2TokensTableMigration extends Migration {
|
||||||
|
@Inject()
|
||||||
|
protected readonly db!: DatabaseService
|
||||||
|
|
||||||
|
async up(): Promise<void> {
|
||||||
|
const schema: Schema = this.db.get().schema()
|
||||||
|
const table = await schema.table('oauth2_tokens')
|
||||||
|
|
||||||
|
table.primaryKey('oauth2_token_id').required()
|
||||||
|
|
||||||
|
table.column('user_id')
|
||||||
|
.type(FieldType.varchar)
|
||||||
|
.nullable()
|
||||||
|
|
||||||
|
table.column('client_id')
|
||||||
|
.type(FieldType.varchar)
|
||||||
|
.required()
|
||||||
|
|
||||||
|
table.column('issued')
|
||||||
|
.type(FieldType.timestamp)
|
||||||
|
.default(raw('NOW()'))
|
||||||
|
.required()
|
||||||
|
|
||||||
|
table.column('expires')
|
||||||
|
.type(FieldType.timestamp)
|
||||||
|
.required()
|
||||||
|
|
||||||
|
table.column('scope')
|
||||||
|
.type(FieldType.varchar)
|
||||||
|
.nullable()
|
||||||
|
|
||||||
|
await schema.commit(table)
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(): Promise<void> {
|
||||||
|
const schema: Schema = this.db.get().schema()
|
||||||
|
const table = await schema.table('oauth2_tokens')
|
||||||
|
|
||||||
|
table.dropIfExists()
|
||||||
|
|
||||||
|
await schema.commit(table)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue