Running into an error when runing `drizzle-kit push:mysql` yet i haven't changed anything

So i seem to be running into this error:
$ pnpm db:push

> [email protected] db:push G:\GitHub\Meally\apps\meally
> drizzle-kit push:mysql --config=drizzle.config.ts

drizzle-kit: v0.19.8
drizzle-orm: v0.27.2

Reading config file 'G:\GitHub\Meally\apps\meally\drizzle.config.ts'
Reading schema files:
G:\GitHub\Meally\apps\meally\src\db\schemas\auth.ts
G:\GitHub\Meally\apps\meally\src\db\schemas\enums.ts
G:\GitHub\Meally\apps\meally\src\db\schemas\groups.ts
G:\GitHub\Meally\apps\meally\src\db\schemas\index.ts
G:\GitHub\Meally\apps\meally\src\db\schemas\recipe.ts

errno: 1067,
sql: 'ALTER TABLE `recipes` MODIFY COLUMN `isPublic` boolean;',
sqlState: '42000',
sqlMessage: `target: meally.-.primary: vttablet: rpc error: code = InvalidArgument desc = Invalid default value for 'createdAt' (errno 1067) (sqlstate 42000) (CallerID: 9d6l772g9pp919ug46mn): Sql: "alter table recipes modify column isPublic boolean", BindVars: {REDACTED}`
}
$ pnpm db:push

> [email protected] db:push G:\GitHub\Meally\apps\meally
> drizzle-kit push:mysql --config=drizzle.config.ts

drizzle-kit: v0.19.8
drizzle-orm: v0.27.2

Reading config file 'G:\GitHub\Meally\apps\meally\drizzle.config.ts'
Reading schema files:
G:\GitHub\Meally\apps\meally\src\db\schemas\auth.ts
G:\GitHub\Meally\apps\meally\src\db\schemas\enums.ts
G:\GitHub\Meally\apps\meally\src\db\schemas\groups.ts
G:\GitHub\Meally\apps\meally\src\db\schemas\index.ts
G:\GitHub\Meally\apps\meally\src\db\schemas\recipe.ts

errno: 1067,
sql: 'ALTER TABLE `recipes` MODIFY COLUMN `isPublic` boolean;',
sqlState: '42000',
sqlMessage: `target: meally.-.primary: vttablet: rpc error: code = InvalidArgument desc = Invalid default value for 'createdAt' (errno 1067) (sqlstate 42000) (CallerID: 9d6l772g9pp919ug46mn): Sql: "alter table recipes modify column isPublic boolean", BindVars: {REDACTED}`
}
This has only just been happening since about the last drizzle update, i have tried changing my schema with no luck. My version of drizzle and drizzle-kit
"drizzle-orm": "^0.27.2",
"drizzle-kit": "^0.19.8",
"drizzle-orm": "^0.27.2",
"drizzle-kit": "^0.19.8",
Please find my schema attached below:
7 Replies
Ahmed
Ahmed2y ago
Are you using planetscale ?
Jacob
JacobOP2y ago
yeh i think that is the issue however it was working, do you know i might fix that?
Ahmed
Ahmed2y ago
If so, you need to hardcode each default value of timestamp fields to use sql from drizzle.
default(sql`CURRENT_TIMESTAMP`)
default(sql`CURRENT_TIMESTAMP`)
defaultNow() is making an invalid default value for planetscale db.
Jacob
JacobOP2y ago
does onUpdateNow() still work as intended or do i need to change that as well?
Ahmed
Ahmed2y ago
onUpdateNow() is working as intended
Jacob
JacobOP2y ago
thank you for your help
thecmdrunner
thecmdrunner2y ago
doesn't seem to be working on me, I'm running into the same error using Planetscale

Did you find this page helpful?