Create migration for oauth2_tokens table
This commit is contained in:
parent
814a5763d9
commit
fd77ad5cd3
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@extollo/lib",
|
"name": "@extollo/lib",
|
||||||
"version": "0.9.39",
|
"version": "0.9.40",
|
||||||
"description": "The framework library that lifts up your code.",
|
"description": "The framework library that lifts up your code.",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"types": "lib/index.d.ts",
|
"types": "lib/index.d.ts",
|
||||||
|
@ -14,7 +14,7 @@ export class OAuth2TokenModel extends Model<OAuth2TokenModel> implements OAuth2T
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Field(FieldType.varchar, 'user_id')
|
@Field(FieldType.varchar, 'user_id')
|
||||||
public userId!: string
|
public userId?: string
|
||||||
|
|
||||||
@Field(FieldType.varchar, 'client_id')
|
@Field(FieldType.varchar, 'client_id')
|
||||||
public clientId!: string
|
public clientId!: string
|
||||||
|
@ -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
Block a user