Browse Source

♻️ refactor(contracts): modify Hetong entity id generation strategy

- change id from manually set varchar(50) to auto-incrementing int using PrimaryGeneratedColumn
- set unsigned: true for id column to ensure positive integer values
yourname 8 months ago
parent
commit
68fe9de13e
1 changed files with 3 additions and 3 deletions
  1. 3 3
      src/server/modules/contracts/hetong.entity.ts

+ 3 - 3
src/server/modules/contracts/hetong.entity.ts

@@ -1,11 +1,11 @@
-import { Entity, PrimaryColumn, Column, Index, ForeignKey } from 'typeorm';
+import { Entity, PrimaryGeneratedColumn, Column, Index, ForeignKey } from 'typeorm';
 import { Client } from '../clients/client.entity';
 import { z } from '@hono/zod-openapi';
 
 @Entity('hetong')
 export class Hetong {
-  @PrimaryColumn({ name: 'id', type: 'varchar', length: 50 })
-  id!: string;
+  @PrimaryGeneratedColumn({ name: 'id', type: 'int', unsigned: true })
+  id!: number;
 
   @Column({ name: 'contract_date', type: 'date' })
   contractDate!: Date;