fix(orm): add explicit PostgreSQL column types for nullable fields

Fixed TypeORM DataTypeNotSupportedError for "Object" type in PostgreSQL.

## Issues Fixed

1. **user-service/UserORM**
   - fingerprint: varchar(255)
   - phone: varchar(20)
   - nickname: varchar(100)
   - avatar: varchar(500)

2. **payment-service/PaymentORM**
   - transactionId: varchar(255)
   - currency: varchar(10)
   - expiresAt: timestamptz
   - paidAt: timestamptz

3. **conversation-service/MessageORM**
   - inputTokens: int
   - outputTokens: int

## Root Cause
@Column({ nullable: true }) without explicit `type` defaults to Object,
which PostgreSQL doesn't support.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-24 22:50:54 -08:00
parent afd707d15f
commit eb1cb9c496
3 changed files with 10 additions and 10 deletions

View File

@ -36,10 +36,10 @@ export class MessageORM {
@Column({ type: 'jsonb', nullable: true })
metadata: Record<string, unknown> | null;
@Column({ name: 'input_tokens', nullable: true })
@Column({ name: 'input_tokens', type: 'int', nullable: true })
inputTokens: number | null;
@Column({ name: 'output_tokens', nullable: true })
@Column({ name: 'output_tokens', type: 'int', nullable: true })
outputTokens: number | null;
@CreateDateColumn({ name: 'created_at', type: 'timestamptz', nullable: true })

View File

@ -20,13 +20,13 @@ export class PaymentORM {
@Column({ type: 'decimal', precision: 10, scale: 2 })
amount: number;
@Column({ default: 'CNY' })
@Column({ type: 'varchar', length: 10, default: 'CNY' })
currency: string;
@Column({ type: 'varchar', length: 50, default: 'PENDING' })
status: string;
@Column({ name: 'transaction_id', nullable: true })
@Column({ name: 'transaction_id', type: 'varchar', length: 255, nullable: true })
transactionId: string | null;
@Column({ name: 'qr_code_url', type: 'text', nullable: true })
@ -35,10 +35,10 @@ export class PaymentORM {
@Column({ name: 'payment_url', type: 'text', nullable: true })
paymentUrl: string | null;
@Column({ name: 'expires_at' })
@Column({ name: 'expires_at', type: 'timestamptz' })
expiresAt: Date;
@Column({ name: 'paid_at', nullable: true })
@Column({ name: 'paid_at', type: 'timestamptz', nullable: true })
paidAt: Date | null;
@Column({ name: 'failed_reason', type: 'text', nullable: true })

View File

@ -22,16 +22,16 @@ export class UserORM {
})
type: string;
@Column({ nullable: true })
@Column({ type: 'varchar', length: 255, nullable: true })
fingerprint: string | null;
@Column({ nullable: true })
@Column({ type: 'varchar', length: 20, nullable: true })
phone: string | null;
@Column({ nullable: true })
@Column({ type: 'varchar', length: 100, nullable: true })
nickname: string | null;
@Column({ nullable: true })
@Column({ type: 'varchar', length: 500, nullable: true })
avatar: string | null;
@CreateDateColumn({ name: 'created_at' })