@nathapp/nestjs-account-prisma 1.0.0 → 1.1.0

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.
package/README.md CHANGED
@@ -50,13 +50,18 @@ Apply it by hand when upgrading an existing database, after
50
50
 
51
51
  ```ts
52
52
  import { Module } from '@nestjs/common';
53
- import { PrismaClient } from '@prisma/client';
53
+ import { PrismaPg } from '@prisma/adapter-pg'; // MySQL: PrismaMariaDb from '@prisma/adapter-mariadb' (host/port/user/password/database, no connectionString)
54
+ import { PrismaClient } from './generated/prisma/client'; // your generator `output`
54
55
  import { PrismaModule } from '@nathapp/nestjs-prisma';
55
56
  import { AccountPrismaModule } from '@nathapp/nestjs-account-prisma';
56
57
 
57
58
  @Module({
58
59
  imports: [
59
- PrismaModule.forRoot({ client: PrismaClient, transaction: true }),
60
+ PrismaModule.forRoot({
61
+ client: PrismaClient,
62
+ clientOptions: { adapter: new PrismaPg({ connectionString: process.env.DATABASE_URL! }) },
63
+ transaction: true,
64
+ }),
60
65
  AccountPrismaModule.register(),
61
66
  ],
62
67
  })
@@ -104,7 +109,8 @@ which is exported from this package if you need to name the type.
104
109
 
105
110
  ## Transactions
106
111
 
107
- Multi-write flows need `PrismaModule.forRoot({ client: PrismaClient, transaction: true })`.
112
+ Multi-write flows need `PrismaModule.forRoot({ client: PrismaClient, transaction: true })`
113
+ with `PrismaClient` imported from your generated client (Prisma 7 `prisma-client` generator).
108
114
  Every repository resolves its client per operation from the `TRANSACTION_MANAGER`
109
115
  token, and the two `PrismaModule` registration paths fail differently when
110
116
  `transaction` is omitted:
@@ -1 +1 @@
1
- {"version":3,"file":"prisma-provider.js","sourceRoot":"","sources":["../lib/prisma-provider.ts"],"names":[],"mappings":";;AAYA,0DAMC;AAND,SAAgB,uBAAuB,CACrC,MAAwB,EACxB,KAAa;IAEb,MAAM,QAAQ,GAAI,MAAwC,CAAC,eAAe,CAAC;IAC3E,OAAO,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;AAC/F,CAAC"}
1
+ {"version":3,"file":"prisma-provider.js","sourceRoot":"","sources":["../lib/prisma-provider.ts"],"names":[],"mappings":";;AAaA,0DAMC;AAND,SAAgB,uBAAuB,CACrC,MAAwB,EACxB,KAAa;IAEb,MAAM,QAAQ,GAAI,MAAwC,CAAC,eAAe,CAAC;IAC3E,OAAO,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC;AAC/F,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nathapp/nestjs-account-prisma",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Prisma adapter for @nathapp/nestjs-account",
5
5
  "scripts": {
6
6
  "build": "rimraf dist && tsc -p tsconfig.json",
@@ -25,17 +25,17 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@nathapp/nestjs-account": "1.0.0",
28
- "@nathapp/nestjs-data": "^3.3.0 || ^4.0.2"
28
+ "@nathapp/nestjs-data": "^3.3.0 || ^4.0.3"
29
29
  },
30
30
  "devDependencies": {
31
- "@nathapp/nestjs-prisma": "^4.0.2",
31
+ "@nathapp/nestjs-prisma": "^4.1.0",
32
32
  "eslint": "^8.57.0",
33
33
  "typescript": "^5"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "@nestjs/common": "^11.0.0 || ^12.1.0",
37
37
  "@nestjs/core": "^11.0.0 || ^12.1.0",
38
- "@nathapp/nestjs-prisma": "^3.3.0 || ^4.0.2",
39
- "@prisma/client": "^6.0.0"
38
+ "@nathapp/nestjs-prisma": "^4.1.0",
39
+ "@prisma/client": "^7.0.0"
40
40
  }
41
41
  }
package/AGENTS.md DELETED
@@ -1,107 +0,0 @@
1
- # Agent Instructions
2
-
3
- This file is auto-generated from `.nax/context.md`.
4
- DO NOT EDIT MANUALLY — run `nax generate` to regenerate.
5
-
6
- These instructions apply to all AI coding agents in this project.
7
-
8
- ---
9
-
10
- ## Project Metadata
11
-
12
- > Auto-injected by `nax generate`
13
-
14
- **Project:** `@nathapp/nestjs-account-prisma`
15
-
16
- **Language:** TypeScript
17
-
18
- **Key dependencies:** @nathapp/nestjs-prisma, typescript
19
-
20
- ---
21
- # CLAUDE.md — @nathapp/nestjs-account-prisma
22
-
23
- Prisma adapter for `@nathapp/nestjs-account`. Binds the 8 account repository
24
- tokens to `AbstractPrismaRepository`-based implementations.
25
-
26
- ## Status: ✅ Complete (all 8 repos on AbstractPrismaRepository)
27
-
28
- ## Implemented Repositories
29
-
30
- - `PrismaAccountRepository` → `IAccountRepository`
31
- - `PrismaMembershipRepository` → `IMembershipRepository`
32
- - `PrismaRoleRepository` → `IRoleRepository` (incl. `rolePermission` join table)
33
- - `PrismaPermissionRepository` → `IPermissionRepository`
34
- - `PrismaInvitationRepository` → `IInvitationRepository`
35
- - `PrismaProfileRepository` → `IProfileRepository`
36
- - `PrismaOnboardingFlowRepository` → `IOnboardingFlowRepository`
37
- - `PrismaOnboardingProgressRepository` → `IOnboardingProgressRepository`
38
-
39
- `AccountPrismaModule.register()` (no-arg) wires all 8 tokens to the concrete
40
- implementations via `useExisting`.
41
-
42
- ## Onboarding Repository Split
43
-
44
- Onboarding was previously a single `ONBOARDING_REPOSITORY` token backed by one
45
- class handling both flow + progress aggregates. It is now split:
46
-
47
- - `ONBOARDING_FLOW_REPOSITORY` — `IOnboardingFlowRepository` (flow definitions)
48
- - `ONBOARDING_PROGRESS_REPOSITORY` — `IOnboardingProgressRepository` (per-account progress + step merges)
49
-
50
- Both extend `IRepository<Domain, string>` from `@nathapp/nestjs-data`.
51
-
52
- ## Wiring (Consumer App)
53
-
54
- The consumer app must register `PrismaModule.forRoot({ transaction: true })` so
55
- `TRANSACTION_MANAGER` is bound. `AccountPrismaModule` then resolves the
56
- transaction-aware client per operation via `tx.getClient()`:
57
-
58
- ```typescript
59
- import { PrismaModule } from '@nathapp/nestjs-prisma';
60
- import { AccountPrismaModule } from '@nathapp/nestjs-account-prisma';
61
-
62
- @Module({
63
- imports: [
64
- PrismaModule.forRoot({ client: PrismaClient, transaction: true }),
65
- AccountPrismaModule.register(),
66
- ],
67
- })
68
- export class AppModule {}
69
- ```
70
-
71
- ## Repository Pattern
72
-
73
- All 8 repositories extend `AbstractPrismaRepository<TDomain, any, string>`
74
- (from `@nathapp/nestjs-prisma`), providing:
75
-
76
- - `modelDelegate(client)` — Prisma model accessor (e.g. `client.account`)
77
- - `toDomain(e)` — persistence row → domain
78
- - `toPersistenceCreate(d)` — domain → Prisma create input (omits `createdAt`/`updatedAt`)
79
- - `toPersistenceUpdate(p)` — partial domain → Prisma update input
80
-
81
- They inherit `findById`, `findOne`, `findAll`, `count`, `create`, `update`,
82
- `delete` from the base class — all transaction-aware.
83
-
84
- ## Dependencies
85
-
86
- - `@nathapp/nestjs-account` (workspace)
87
- - `@nathapp/nestjs-data` ^3.2.0 (peer)
88
- - `@nathapp/nestjs-prisma` ^3.2.0 (peer)
89
- - `@prisma/client` ^6.0.0 (peer)
90
-
91
- ## Schema conventions
92
-
93
- All `DateTime` fields in the consumer's `schema.prisma` for account models (Account, Membership, Role, Permission, Invitation, Profile, OnboardingFlow, OnboardingProgress) MUST use `@db.Timestamptz(6)`:
94
-
95
- ```prisma
96
- createdAt DateTime @db.Timestamptz(6) @default(now()) @map("created_at")
97
- updatedAt DateTime @db.Timestamptz(6) @updatedAt @map("updated_at")
98
- expiresAt DateTime @db.Timestamptz(6) @map("expires_at")
99
- ```
100
-
101
- This maps to PostgreSQL `timestamptz`, which stores UTC and converts correctly regardless of DB server timezone. Bare `DateTime` (maps to `timestamp without time zone`) is NOT correct for this platform.
102
-
103
- When migrating an existing database:
104
- ```sql
105
- ALTER TABLE <table> ALTER COLUMN <col> TYPE TIMESTAMPTZ(6) USING <col> AT TIME ZONE 'UTC';
106
- ```
107
- Run one statement per column. Verify `SHOW timezone;` returns `UTC` before migrating production data.
package/CLAUDE.md DELETED
@@ -1,105 +0,0 @@
1
- # Project Context
2
-
3
- This file is auto-generated from `.nax/context.md`.
4
- DO NOT EDIT MANUALLY — run `nax generate` to regenerate.
5
-
6
- ---
7
-
8
- ## Project Metadata
9
-
10
- > Auto-injected by `nax generate`
11
-
12
- **Project:** `@nathapp/nestjs-account-prisma`
13
-
14
- **Language:** TypeScript
15
-
16
- **Key dependencies:** @nathapp/nestjs-prisma, typescript
17
-
18
- ---
19
- # CLAUDE.md — @nathapp/nestjs-account-prisma
20
-
21
- Prisma adapter for `@nathapp/nestjs-account`. Binds the 8 account repository
22
- tokens to `AbstractPrismaRepository`-based implementations.
23
-
24
- ## Status: ✅ Complete (all 8 repos on AbstractPrismaRepository)
25
-
26
- ## Implemented Repositories
27
-
28
- - `PrismaAccountRepository` → `IAccountRepository`
29
- - `PrismaMembershipRepository` → `IMembershipRepository`
30
- - `PrismaRoleRepository` → `IRoleRepository` (incl. `rolePermission` join table)
31
- - `PrismaPermissionRepository` → `IPermissionRepository`
32
- - `PrismaInvitationRepository` → `IInvitationRepository`
33
- - `PrismaProfileRepository` → `IProfileRepository`
34
- - `PrismaOnboardingFlowRepository` → `IOnboardingFlowRepository`
35
- - `PrismaOnboardingProgressRepository` → `IOnboardingProgressRepository`
36
-
37
- `AccountPrismaModule.register()` (no-arg) wires all 8 tokens to the concrete
38
- implementations via `useExisting`.
39
-
40
- ## Onboarding Repository Split
41
-
42
- Onboarding was previously a single `ONBOARDING_REPOSITORY` token backed by one
43
- class handling both flow + progress aggregates. It is now split:
44
-
45
- - `ONBOARDING_FLOW_REPOSITORY` — `IOnboardingFlowRepository` (flow definitions)
46
- - `ONBOARDING_PROGRESS_REPOSITORY` — `IOnboardingProgressRepository` (per-account progress + step merges)
47
-
48
- Both extend `IRepository<Domain, string>` from `@nathapp/nestjs-data`.
49
-
50
- ## Wiring (Consumer App)
51
-
52
- The consumer app must register `PrismaModule.forRoot({ transaction: true })` so
53
- `TRANSACTION_MANAGER` is bound. `AccountPrismaModule` then resolves the
54
- transaction-aware client per operation via `tx.getClient()`:
55
-
56
- ```typescript
57
- import { PrismaModule } from '@nathapp/nestjs-prisma';
58
- import { AccountPrismaModule } from '@nathapp/nestjs-account-prisma';
59
-
60
- @Module({
61
- imports: [
62
- PrismaModule.forRoot({ client: PrismaClient, transaction: true }),
63
- AccountPrismaModule.register(),
64
- ],
65
- })
66
- export class AppModule {}
67
- ```
68
-
69
- ## Repository Pattern
70
-
71
- All 8 repositories extend `AbstractPrismaRepository<TDomain, any, string>`
72
- (from `@nathapp/nestjs-prisma`), providing:
73
-
74
- - `modelDelegate(client)` — Prisma model accessor (e.g. `client.account`)
75
- - `toDomain(e)` — persistence row → domain
76
- - `toPersistenceCreate(d)` — domain → Prisma create input (omits `createdAt`/`updatedAt`)
77
- - `toPersistenceUpdate(p)` — partial domain → Prisma update input
78
-
79
- They inherit `findById`, `findOne`, `findAll`, `count`, `create`, `update`,
80
- `delete` from the base class — all transaction-aware.
81
-
82
- ## Dependencies
83
-
84
- - `@nathapp/nestjs-account` (workspace)
85
- - `@nathapp/nestjs-data` ^3.2.0 (peer)
86
- - `@nathapp/nestjs-prisma` ^3.2.0 (peer)
87
- - `@prisma/client` ^6.0.0 (peer)
88
-
89
- ## Schema conventions
90
-
91
- All `DateTime` fields in the consumer's `schema.prisma` for account models (Account, Membership, Role, Permission, Invitation, Profile, OnboardingFlow, OnboardingProgress) MUST use `@db.Timestamptz(6)`:
92
-
93
- ```prisma
94
- createdAt DateTime @db.Timestamptz(6) @default(now()) @map("created_at")
95
- updatedAt DateTime @db.Timestamptz(6) @updatedAt @map("updated_at")
96
- expiresAt DateTime @db.Timestamptz(6) @map("expires_at")
97
- ```
98
-
99
- This maps to PostgreSQL `timestamptz`, which stores UTC and converts correctly regardless of DB server timezone. Bare `DateTime` (maps to `timestamp without time zone`) is NOT correct for this platform.
100
-
101
- When migrating an existing database:
102
- ```sql
103
- ALTER TABLE <table> ALTER COLUMN <col> TYPE TIMESTAMPTZ(6) USING <col> AT TIME ZONE 'UTC';
104
- ```
105
- Run one statement per column. Verify `SHOW timezone;` returns `UTC` before migrating production data.
package/GEMINI.md DELETED
@@ -1,105 +0,0 @@
1
- # Gemini CLI Context
2
-
3
- This file is auto-generated from `.nax/context.md`.
4
- DO NOT EDIT MANUALLY — run `nax generate` to regenerate.
5
-
6
- ---
7
-
8
- ## Project Metadata
9
-
10
- > Auto-injected by `nax generate`
11
-
12
- **Project:** `@nathapp/nestjs-account-prisma`
13
-
14
- **Language:** TypeScript
15
-
16
- **Key dependencies:** @nathapp/nestjs-prisma, typescript
17
-
18
- ---
19
- # CLAUDE.md — @nathapp/nestjs-account-prisma
20
-
21
- Prisma adapter for `@nathapp/nestjs-account`. Binds the 8 account repository
22
- tokens to `AbstractPrismaRepository`-based implementations.
23
-
24
- ## Status: ✅ Complete (all 8 repos on AbstractPrismaRepository)
25
-
26
- ## Implemented Repositories
27
-
28
- - `PrismaAccountRepository` → `IAccountRepository`
29
- - `PrismaMembershipRepository` → `IMembershipRepository`
30
- - `PrismaRoleRepository` → `IRoleRepository` (incl. `rolePermission` join table)
31
- - `PrismaPermissionRepository` → `IPermissionRepository`
32
- - `PrismaInvitationRepository` → `IInvitationRepository`
33
- - `PrismaProfileRepository` → `IProfileRepository`
34
- - `PrismaOnboardingFlowRepository` → `IOnboardingFlowRepository`
35
- - `PrismaOnboardingProgressRepository` → `IOnboardingProgressRepository`
36
-
37
- `AccountPrismaModule.register()` (no-arg) wires all 8 tokens to the concrete
38
- implementations via `useExisting`.
39
-
40
- ## Onboarding Repository Split
41
-
42
- Onboarding was previously a single `ONBOARDING_REPOSITORY` token backed by one
43
- class handling both flow + progress aggregates. It is now split:
44
-
45
- - `ONBOARDING_FLOW_REPOSITORY` — `IOnboardingFlowRepository` (flow definitions)
46
- - `ONBOARDING_PROGRESS_REPOSITORY` — `IOnboardingProgressRepository` (per-account progress + step merges)
47
-
48
- Both extend `IRepository<Domain, string>` from `@nathapp/nestjs-data`.
49
-
50
- ## Wiring (Consumer App)
51
-
52
- The consumer app must register `PrismaModule.forRoot({ transaction: true })` so
53
- `TRANSACTION_MANAGER` is bound. `AccountPrismaModule` then resolves the
54
- transaction-aware client per operation via `tx.getClient()`:
55
-
56
- ```typescript
57
- import { PrismaModule } from '@nathapp/nestjs-prisma';
58
- import { AccountPrismaModule } from '@nathapp/nestjs-account-prisma';
59
-
60
- @Module({
61
- imports: [
62
- PrismaModule.forRoot({ client: PrismaClient, transaction: true }),
63
- AccountPrismaModule.register(),
64
- ],
65
- })
66
- export class AppModule {}
67
- ```
68
-
69
- ## Repository Pattern
70
-
71
- All 8 repositories extend `AbstractPrismaRepository<TDomain, any, string>`
72
- (from `@nathapp/nestjs-prisma`), providing:
73
-
74
- - `modelDelegate(client)` — Prisma model accessor (e.g. `client.account`)
75
- - `toDomain(e)` — persistence row → domain
76
- - `toPersistenceCreate(d)` — domain → Prisma create input (omits `createdAt`/`updatedAt`)
77
- - `toPersistenceUpdate(p)` — partial domain → Prisma update input
78
-
79
- They inherit `findById`, `findOne`, `findAll`, `count`, `create`, `update`,
80
- `delete` from the base class — all transaction-aware.
81
-
82
- ## Dependencies
83
-
84
- - `@nathapp/nestjs-account` (workspace)
85
- - `@nathapp/nestjs-data` ^3.2.0 (peer)
86
- - `@nathapp/nestjs-prisma` ^3.2.0 (peer)
87
- - `@prisma/client` ^6.0.0 (peer)
88
-
89
- ## Schema conventions
90
-
91
- All `DateTime` fields in the consumer's `schema.prisma` for account models (Account, Membership, Role, Permission, Invitation, Profile, OnboardingFlow, OnboardingProgress) MUST use `@db.Timestamptz(6)`:
92
-
93
- ```prisma
94
- createdAt DateTime @db.Timestamptz(6) @default(now()) @map("created_at")
95
- updatedAt DateTime @db.Timestamptz(6) @updatedAt @map("updated_at")
96
- expiresAt DateTime @db.Timestamptz(6) @map("expires_at")
97
- ```
98
-
99
- This maps to PostgreSQL `timestamptz`, which stores UTC and converts correctly regardless of DB server timezone. Bare `DateTime` (maps to `timestamp without time zone`) is NOT correct for this platform.
100
-
101
- When migrating an existing database:
102
- ```sql
103
- ALTER TABLE <table> ALTER COLUMN <col> TYPE TIMESTAMPTZ(6) USING <col> AT TIME ZONE 'UTC';
104
- ```
105
- Run one statement per column. Verify `SHOW timezone;` returns `UTC` before migrating production data.
package/codex.md DELETED
@@ -1,105 +0,0 @@
1
- # Codex Instructions
2
-
3
- This file is auto-generated from `.nax/context.md`.
4
- DO NOT EDIT MANUALLY — run `nax generate` to regenerate.
5
-
6
- ---
7
-
8
- ## Project Metadata
9
-
10
- > Auto-injected by `nax generate`
11
-
12
- **Project:** `@nathapp/nestjs-account-prisma`
13
-
14
- **Language:** TypeScript
15
-
16
- **Key dependencies:** @nathapp/nestjs-prisma, typescript
17
-
18
- ---
19
- # CLAUDE.md — @nathapp/nestjs-account-prisma
20
-
21
- Prisma adapter for `@nathapp/nestjs-account`. Binds the 8 account repository
22
- tokens to `AbstractPrismaRepository`-based implementations.
23
-
24
- ## Status: ✅ Complete (all 8 repos on AbstractPrismaRepository)
25
-
26
- ## Implemented Repositories
27
-
28
- - `PrismaAccountRepository` → `IAccountRepository`
29
- - `PrismaMembershipRepository` → `IMembershipRepository`
30
- - `PrismaRoleRepository` → `IRoleRepository` (incl. `rolePermission` join table)
31
- - `PrismaPermissionRepository` → `IPermissionRepository`
32
- - `PrismaInvitationRepository` → `IInvitationRepository`
33
- - `PrismaProfileRepository` → `IProfileRepository`
34
- - `PrismaOnboardingFlowRepository` → `IOnboardingFlowRepository`
35
- - `PrismaOnboardingProgressRepository` → `IOnboardingProgressRepository`
36
-
37
- `AccountPrismaModule.register()` (no-arg) wires all 8 tokens to the concrete
38
- implementations via `useExisting`.
39
-
40
- ## Onboarding Repository Split
41
-
42
- Onboarding was previously a single `ONBOARDING_REPOSITORY` token backed by one
43
- class handling both flow + progress aggregates. It is now split:
44
-
45
- - `ONBOARDING_FLOW_REPOSITORY` — `IOnboardingFlowRepository` (flow definitions)
46
- - `ONBOARDING_PROGRESS_REPOSITORY` — `IOnboardingProgressRepository` (per-account progress + step merges)
47
-
48
- Both extend `IRepository<Domain, string>` from `@nathapp/nestjs-data`.
49
-
50
- ## Wiring (Consumer App)
51
-
52
- The consumer app must register `PrismaModule.forRoot({ transaction: true })` so
53
- `TRANSACTION_MANAGER` is bound. `AccountPrismaModule` then resolves the
54
- transaction-aware client per operation via `tx.getClient()`:
55
-
56
- ```typescript
57
- import { PrismaModule } from '@nathapp/nestjs-prisma';
58
- import { AccountPrismaModule } from '@nathapp/nestjs-account-prisma';
59
-
60
- @Module({
61
- imports: [
62
- PrismaModule.forRoot({ client: PrismaClient, transaction: true }),
63
- AccountPrismaModule.register(),
64
- ],
65
- })
66
- export class AppModule {}
67
- ```
68
-
69
- ## Repository Pattern
70
-
71
- All 8 repositories extend `AbstractPrismaRepository<TDomain, any, string>`
72
- (from `@nathapp/nestjs-prisma`), providing:
73
-
74
- - `modelDelegate(client)` — Prisma model accessor (e.g. `client.account`)
75
- - `toDomain(e)` — persistence row → domain
76
- - `toPersistenceCreate(d)` — domain → Prisma create input (omits `createdAt`/`updatedAt`)
77
- - `toPersistenceUpdate(p)` — partial domain → Prisma update input
78
-
79
- They inherit `findById`, `findOne`, `findAll`, `count`, `create`, `update`,
80
- `delete` from the base class — all transaction-aware.
81
-
82
- ## Dependencies
83
-
84
- - `@nathapp/nestjs-account` (workspace)
85
- - `@nathapp/nestjs-data` ^3.2.0 (peer)
86
- - `@nathapp/nestjs-prisma` ^3.2.0 (peer)
87
- - `@prisma/client` ^6.0.0 (peer)
88
-
89
- ## Schema conventions
90
-
91
- All `DateTime` fields in the consumer's `schema.prisma` for account models (Account, Membership, Role, Permission, Invitation, Profile, OnboardingFlow, OnboardingProgress) MUST use `@db.Timestamptz(6)`:
92
-
93
- ```prisma
94
- createdAt DateTime @db.Timestamptz(6) @default(now()) @map("created_at")
95
- updatedAt DateTime @db.Timestamptz(6) @updatedAt @map("updated_at")
96
- expiresAt DateTime @db.Timestamptz(6) @map("expires_at")
97
- ```
98
-
99
- This maps to PostgreSQL `timestamptz`, which stores UTC and converts correctly regardless of DB server timezone. Bare `DateTime` (maps to `timestamp without time zone`) is NOT correct for this platform.
100
-
101
- When migrating an existing database:
102
- ```sql
103
- ALTER TABLE <table> ALTER COLUMN <col> TYPE TIMESTAMPTZ(6) USING <col> AT TIME ZONE 'UTC';
104
- ```
105
- Run one statement per column. Verify `SHOW timezone;` returns `UTC` before migrating production data.