File tree 2 files changed +30
-4
lines changed
migrations/20250501144025_cleanup_trolley_log_table
2 files changed +30
-4
lines changed Original file line number Diff line number Diff line change
1
+ BEGIN ;
2
+
3
+ -- Step 1: Drop unused metadata columns
4
+ ALTER TABLE " trolley_webhook_log"
5
+ DROP COLUMN " created_by" ,
6
+ DROP COLUMN " updated_at" ,
7
+ DROP COLUMN " updated_by" ;
8
+
9
+ -- Step 2: Add new JSONB column
10
+ ALTER TABLE " trolley_webhook_log"
11
+ ADD COLUMN " event_payload_json" JSONB;
12
+
13
+ -- Step 3: Migrate data from old stringified JSON column to new JSONB column
14
+ UPDATE " trolley_webhook_log"
15
+ SET " event_payload_json" = " event_payload" ::jsonb;
16
+
17
+ -- Step 4: Drop old column
18
+ ALTER TABLE " trolley_webhook_log"
19
+ DROP COLUMN " event_payload" ;
20
+
21
+ -- Step 5: Rename new column to match original name
22
+ ALTER TABLE " trolley_webhook_log"
23
+ RENAME COLUMN " event_payload_json" TO " event_payload" ;
24
+
25
+ -- Step 6: Apply NOT NULL constraint
26
+ ALTER TABLE " trolley_webhook_log"
27
+ ALTER COLUMN " event_payload" SET NOT NULL ;
28
+
29
+ COMMIT ;
Original file line number Diff line number Diff line change @@ -204,15 +204,12 @@ model trolley_webhook_log {
204
204
id String @id @default (dbgenerated (" uuid_generate_v4 ()" ) ) @db.Uuid
205
205
event_id String @unique
206
206
event_time DateTime @default (now () ) @db.Timestamp (6 )
207
- event_payload String
207
+ event_payload Json
208
208
event_model String ?
209
209
event_action String ?
210
210
status webhook_status
211
211
error_message String ?
212
- created_by String ? @db.VarChar (80 )
213
- updated_by String ? @db.VarChar (80 )
214
212
created_at DateTime ? @default (now () ) @db.Timestamp (6 )
215
- updated_at DateTime ? @default (now () ) @db.Timestamp (6 )
216
213
}
217
214
218
215
model trolley_recipient_payment_method {
You can’t perform that action at this time.
0 commit comments