Closed avallete closed 7 months ago
Testing sqlite database [https://github.com/remix-run/example-trellix](https://github.com/remix-run/example-trellix) We can see that the "created_at" defined by prisma like so `created_at DATETIME DEFAULT CURENT_TIMESTAMP` get seeded like a text field and seeded with a "date as string". What's expected here by the definition and `DATETIME` field is a timestamp (number of seconds). We should improve our current sqlite transformations to detect this case of usage and seed with the proper value.
Changes:
There is some TODO. Notably we have a chicken-egg problem with dates in sqlite and prisma.Basically:~~1. in SQLite, dates are stored as string in ISO format so when you do something like
SELECT CURRENT_TIMESTAMP
The result is something like:2024-04-10 23:07:53
~~2. Prisma will generate a migration for sqlite with a@Datetime
column looking like:createdAt DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
BUT while prisma declare this in the database, it work differently:1. Prisma use it's own convention (numeric timestamp) inside those columns, for all Date fields.2. Prisma doesn't really rely on the sqlite database default value to generate the dates (otherwise the createdAt would take a string values)So I made change so users using prisma with sqlite and caring about dates can override their models with somethinglike:What would be great is if we could do that automatically on all "Date" fields if we know the adapter used is prisma. But I couldn't find the right abstraction yet. I think I'll need @jgoux and @justinvdm on this.Has also been solved by adding the capacity for the adapter to patch the userModels values: https://github.com/snaplet/seed/pull/111
Fixes S-1978