forked from Shared/esg
database migrated to POSTGRESQL
This commit is contained in:
@@ -1,44 +1,44 @@
|
||||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
|
||||
import { HydratedDocument } from 'mongoose';
|
||||
|
||||
export type GeneralTokenDocument = HydratedDocument<GeneralToken>;
|
||||
import { Column, CreateDateColumn, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
|
||||
|
||||
/** OAuth tokens for outbound provider APIs — credentials stay in env, not stored here. */
|
||||
@Schema({ timestamps: { createdAt: true, updatedAt: false }, collection: 'general_tokens' })
|
||||
@Entity('general_tokens')
|
||||
@Index(['serviceProvider', 'createdAt'])
|
||||
export class GeneralToken {
|
||||
@Prop({ required: true, index: true })
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id!: string;
|
||||
|
||||
@Index()
|
||||
@Column({ type: 'text' })
|
||||
serviceProvider!: string;
|
||||
|
||||
@Prop({ required: true })
|
||||
@Column({ type: 'text' })
|
||||
tokenType!: string;
|
||||
|
||||
@Prop({ required: true })
|
||||
@Column({ type: 'text' })
|
||||
url!: string;
|
||||
|
||||
@Prop({ required: true })
|
||||
@Column({ type: 'text' })
|
||||
clientId!: string;
|
||||
|
||||
@Prop({ required: true })
|
||||
@Column({ type: 'text' })
|
||||
username!: string;
|
||||
|
||||
@Prop({ required: true })
|
||||
@Column({ type: 'text' })
|
||||
scope!: string;
|
||||
|
||||
@Prop({ required: true })
|
||||
@Column({ type: 'text' })
|
||||
accessToken!: string;
|
||||
|
||||
@Prop()
|
||||
refreshToken?: string;
|
||||
@Column({ type: 'text', nullable: true })
|
||||
refreshToken?: string | null;
|
||||
|
||||
@Prop({ required: true })
|
||||
@Column({ type: 'int' })
|
||||
expiresIn!: number;
|
||||
|
||||
@Prop({ required: true, index: true })
|
||||
@Index()
|
||||
@Column({ type: 'timestamptz' })
|
||||
expiresAt!: Date;
|
||||
|
||||
createdAt?: Date;
|
||||
@CreateDateColumn({ type: 'timestamptz' })
|
||||
createdAt!: Date;
|
||||
}
|
||||
|
||||
export const GeneralTokenSchema = SchemaFactory.createForClass(GeneralToken);
|
||||
|
||||
GeneralTokenSchema.index({ serviceProvider: 1, createdAt: -1 });
|
||||
|
||||
Reference in New Issue
Block a user