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.
47 lines
1.2 KiB
47 lines
1.2 KiB
import {DatabaseService, FieldType, Migration, Schema} from '../orm'
|
|
import {Inject} from '../di'
|
|
|
|
export default class CreateOAuth2TokensTableMigration extends Migration {
|
|
@Inject()
|
|
protected readonly db!: DatabaseService
|
|
|
|
async up(): Promise<void> {
|
|
const db = this.db.get()
|
|
const table = await db.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(db.dialect().currentTimestamp())
|
|
.required()
|
|
|
|
table.column('expires')
|
|
.type(FieldType.timestamp)
|
|
.required()
|
|
|
|
table.column('scope')
|
|
.type(FieldType.varchar)
|
|
.nullable()
|
|
|
|
await db.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)
|
|
}
|
|
}
|