proflores-db-model 0.2.34 → 0.2.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  import { Budget } from '../apu';
2
2
  export declare class BudgetSnapshot {
3
3
  idSnapshot: number;
4
- idBudget: number;
5
4
  budget: Budget;
5
+ idBudget: number;
6
6
  payload: Record<string, any>;
7
7
  pdfHash?: string | null;
8
8
  idPriceList?: number;
@@ -19,25 +19,25 @@ __decorate([
19
19
  (0, typeorm_1.PrimaryGeneratedColumn)(),
20
20
  __metadata("design:type", Number)
21
21
  ], BudgetSnapshot.prototype, "idSnapshot", void 0);
22
- __decorate([
23
- (0, typeorm_1.Column)(),
24
- __metadata("design:type", Number)
25
- ], BudgetSnapshot.prototype, "idBudget", void 0);
26
22
  __decorate([
27
23
  (0, typeorm_1.ManyToOne)(() => apu_1.Budget, { onDelete: 'CASCADE' }),
28
24
  (0, typeorm_1.JoinColumn)({ name: 'idBudget' }),
29
25
  __metadata("design:type", apu_1.Budget)
30
26
  ], BudgetSnapshot.prototype, "budget", void 0);
27
+ __decorate([
28
+ (0, typeorm_1.RelationId)((s) => s.budget),
29
+ __metadata("design:type", Number)
30
+ ], BudgetSnapshot.prototype, "idBudget", void 0);
31
31
  __decorate([
32
32
  (0, typeorm_1.Column)({ type: 'jsonb' }),
33
33
  __metadata("design:type", Object)
34
34
  ], BudgetSnapshot.prototype, "payload", void 0);
35
35
  __decorate([
36
- (0, typeorm_1.Column)({ nullable: true, length: 64 }),
36
+ (0, typeorm_1.Column)({ type: 'varchar', length: 64, nullable: true }),
37
37
  __metadata("design:type", Object)
38
38
  ], BudgetSnapshot.prototype, "pdfHash", void 0);
39
39
  __decorate([
40
- (0, typeorm_1.Column)({ nullable: true }),
40
+ (0, typeorm_1.Column)({ type: 'int', nullable: true }),
41
41
  __metadata("design:type", Number)
42
42
  ], BudgetSnapshot.prototype, "idPriceList", void 0);
43
43
  __decorate([
@@ -49,11 +49,11 @@ __decorate([
49
49
  __metadata("design:type", Number)
50
50
  ], BudgetSnapshot.prototype, "total", void 0);
51
51
  __decorate([
52
- (0, typeorm_1.CreateDateColumn)(),
52
+ (0, typeorm_1.CreateDateColumn)({ type: 'timestamptz' }),
53
53
  __metadata("design:type", Date)
54
54
  ], BudgetSnapshot.prototype, "createdAt", void 0);
55
55
  __decorate([
56
- (0, typeorm_1.Column)({ nullable: true }),
56
+ (0, typeorm_1.Column)({ type: 'varchar', length: 128, nullable: true }),
57
57
  __metadata("design:type", String)
58
58
  ], BudgetSnapshot.prototype, "generatedBy", void 0);
59
59
  __decorate([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proflores-db-model",
3
- "version": "0.2.34",
3
+ "version": "0.2.35",
4
4
  "description": "Data model for managing expenses and transactions for Proflores nursery business",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,4 +1,4 @@
1
- import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, ManyToOne, JoinColumn, Index } from 'typeorm';
1
+ import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, ManyToOne, JoinColumn, Index, RelationId } from 'typeorm';
2
2
  import { Budget } from '../apu';
3
3
 
4
4
  @Entity('budget_snapshots')
@@ -8,20 +8,21 @@ export class BudgetSnapshot {
8
8
  @PrimaryGeneratedColumn()
9
9
  idSnapshot!: number;
10
10
 
11
- @Column()
12
- idBudget!: number;
13
-
14
11
  @ManyToOne(() => Budget, { onDelete: 'CASCADE' })
15
12
  @JoinColumn({ name: 'idBudget' })
16
13
  budget!: Budget;
17
14
 
15
+ @RelationId((s: BudgetSnapshot) => s.budget)
16
+ idBudget!: number;
17
+
18
18
  @Column({ type: 'jsonb' })
19
- payload!: Record<string, any>;
19
+ payload!: Record<string, any>;
20
20
 
21
- @Column({ nullable: true, length: 64 })
21
+ // Si vas a guardar el hash con prefijo 0x, usa length: 66; si no, 64 está bien
22
+ @Column({ type: 'varchar', length: 64, nullable: true })
22
23
  pdfHash?: string | null;
23
24
 
24
- @Column({ nullable: true })
25
+ @Column({ type: 'int', nullable: true })
25
26
  idPriceList?: number;
26
27
 
27
28
  @Column({ type: 'varchar', length: 10, default: 'MXN' })
@@ -30,12 +31,13 @@ export class BudgetSnapshot {
30
31
  @Column({ type: 'decimal', precision: 20, scale: 4 })
31
32
  total!: number;
32
33
 
33
- @CreateDateColumn()
34
+ // Especifica el tipo para evitar diferencias entre drivers
35
+ @CreateDateColumn({ type: 'timestamptz' })
34
36
  createdAt!: Date;
35
37
 
36
- @Column({ nullable: true })
37
- generatedBy?: string;
38
+ @Column({ type: 'varchar', length: 128, nullable: true })
39
+ generatedBy?: string;
38
40
 
39
41
  @Column({ type: 'text', nullable: true })
40
- notes?: string;
41
- }
42
+ notes?: string;
43
+ }