Closed kelbyfaessler closed 7 months ago
Thank you for bringing up the issue @kelbyfaessler . Would you have a code / SQL that reproduces the issue?
I played around with the generated SQL and figured out the issue.
The issue is in this part of a table definition
CREATE TABLE `mytable` (
...
`created_at` text DEFAULT strftime('%Y-%m-%dT%H:%M:%fZ', 'now') NOT NULL,
...
);
If I put parens around the strftime call, then it works
`created_at` text DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')) NOT NULL,
closing the issue since its a drizzle issue with their generated sql
@kelbyfaessler сan you show the drizzle schema you are using?
@AndriiSherman the line in the schema looks like this:
createdAt: text("created_at").notNull().default(sql`strftime('%Y-%m-%dT%H:%M:%fZ', 'now')`),
which means its not a drizzle issue and rather issue with my own code, right? Since I could insert the parens like so
createdAt: text("created_at").notNull().default(sql`(strftime('%Y-%m-%dT%H:%M:%fZ', 'now'))`),
According to my understanding you're right @kelbyfaessler. This is an issue with the code not drizzle itself but @AndriiSherman will know better.
Author
Yes, so the case here is that if you are using the sql
template in the drizzle schema, we can't know exactly what is there because it can be basically anything. It's done to not block you from using anything you need while we are implementing first-class support for a specific feature. So it means anything that is in the sql
template will be added after the default as-is, so it is your responsibility to put the right code there, same as you would put in raw sql DDL statement after DEFAULT
Using Turso with drizzle + sveltekit. Sveltekit has import aliases like $env, $lib and for that reason, I run scripts using vite-node so imports resolve.
I created a migration and am attempting to migrate using drizzles migrate() function. Here is the libsql/hrana error.