Local Testing for D1?
before, to test locally with drizzle and d1:
i used to do this, i am aware :sqlite is deprecated since we have a config file.
but initializing a local db no longer works:
✘ [ERROR] near ")": syntax error at offset 57: SQLITE_ERROR
I looked into the push command but it looks like it directly applies changes to the production database? What is the correct way to create a local database now.5 Replies
This seems to be a syntax error. Maybe that shell is not producing the result you're expecting?
I've worked in projects where we have different config files that you can pass to drizzle-kit cli with the
--config
optionProd vs dev config, the only thing is, how would i make a local database that i can use for d1 local development
Not familiar with d1, maybe someone else can help
Unfortunately there are not enough people to help
I will try to figure it out man
Found out the issue, when using wrangler to apply migrations to the local database.
the migration file included an empty table that i defined and forgot about:
maybe there should be a warning shown when generating tables that are empty? I am not sure, but if this is intended behavior, my apologies
SOLVED
Maybe also check this dynamic config for d1 this other thread: https://discord.com/channels/1043890932593987624/1265077849002475571
I have these scripts added to my package.json:
db:local
is needed to create the local DB if it not yet exists in the .wrangler directory
db:reset
is needed to use push
when the table already exists. I don't like this though. Is there another way you know about? Would be nice if push
would use CREATE TABLE IF NOT EXIST
to prevent such errors.