can I have a look at the toml file also
can I have a look at the toml file? also, are you using pages or workers?
22 Replies
pages
have you set up preview_database_id = "DB" in the environment you use for local?
no
also how do you run it?
because this is mone
wrangler pages dev --compatibility-date=2023-01-01 ./pages --kv=KV --d1=DB
please do not share database IDs 😄
theres nothing in it
of value anyway
yeah but people peeking at schemas might reveal flaws
this is mine
I just wanna be able to dev locally, or I'll use another db
[env.production]
kv_namespaces =[
{ binding = "SESSION_KV", id = "xxxxxxxxxx" }
]
d1_databases = [
{binding = "DB", database_name = "nekotest",database_id = "xxxxxxxxxx" }]
[env.preview]
kv_namespaces =[
{ binding = "SESSION_KV", id = "xxxxxxxxxx" }
]
d1_databases = [
{binding = "DB", database_name = "nekotest-preview", database_id = "xxxxxxxxxx", preview_database_id = "DB" }]
It needed preview_database_id
to workPages doesn't use Wrangler.toml - it's all done by CLI flags on
pages dev
ok, then that must have been completely ineffective black magic
so this toml isnt doing anything?
well, it is used by wrangler migrations
i can see the sqlite files, I assume I have multiple local databases in use, can I purge these and recreate from my remote? i assume thats what the migration should do
you can totally remove the directory and migrate again
if I try to migrate my database it cant find it locally, I am not passing --local
the rest of the api suggests these calls are remote unless you pass --local
also I assume I need the wrangle file if I am using wrangle in my project
ah ok, so a migration assumes the changes are local and can be pushed to remotely, which makes sense
thanks @Lost Pages it mentions here
preview_database_id
is required for pages local developmentwoot!
daily reminder the devil is still in fact in the detail
my understanding is that at some point pages will use wrangler.toml to set up things in prod, but wrangler locally uses it now to do migrations
and there is no complete example with separate environments and preview_database_id so it took me time and i'm old
yeah the docs are not clear on the local dev part, thanks for your help
I'm glad it worked!
migrations still user wrangler.toml, so if you use migrations you still need it