prisma db push is failing on relation
Hello 👋, when trying to apply a new SQLite schema it throws this error complaining something is wrong with the relation. I hope someone experienced can help me, thanks for taking your time!
Error: SQLite database error
near "(": syntax error in CREATE TABLE "sessions" (
"session_token" TEXT NOT NULL,
"user_id" TEXT NOT NULL,
"created_at" INTEGER NOT NULL DEFAULT strftime('%s', 'now'),
"expires_at" INTEGER NOT NULL,
PRIMARY KEY ("user_id", "session_token"),
CONSTRAINT "sessions_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
) at offset 140
0: sql_schema_connector::apply_migration::apply_migration
at schema-engine\connectors\sql-schema-connector\src\apply_migration.rs:10
1: schema_core::state::SchemaPush
at schema-engine\core\src\state.rs:434
Prisma Schema:
5 Replies
I found out that this is the reason it throws:
created_at Int @default(dbgenerated("strftime('%s', 'now')"))
is there maybe a way I can handle this differently?
I'm guessing you would like that to be the time at which the model is created?
exactly
yup it's just
@default(now())
Thanks! Is there maybe also a in 30days (any time for that matter) function?