Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 BUG: unable to apply migrations on preview_database_id in D1 #2446

Closed
verokarhu opened this issue Dec 22, 2022 · 1 comment 路 Fixed by #2715
Closed

馃悰 BUG: unable to apply migrations on preview_database_id in D1 #2446

verokarhu opened this issue Dec 22, 2022 · 1 comment 路 Fixed by #2715
Assignees
Labels
bug Something that isn't working d1 Relating to D1

Comments

@verokarhu
Copy link
Contributor

What version of Wrangler are you using?

2.6.2

What operating system are you using?

Mac

Describe the Bug

Trying to apply a migration to the preview database with the command:
wrangler d1 migrations apply database-dev
returns the error:
[ERROR] Can't find a DB with name/binding 'database-dev' in local config. Check info in wrangler.toml...

The wrangler.toml file has the following configuration:
d1_databases = [ { binding = "DATABASE", database_id = "<UUID for database-prod>", database_name = "database-prod", preview_database_id = "<UUID for database-dev>" }, ]

I've worked around the problem by adding the following section to the wrangler.toml file:
[env.dev] d1_databases = [ { binding = "DATABASE", database_id = "<UUID for database-dev>", database_name = "database-dev" }, ]
which allows me to apply the migrations by running:
wrangler d1 migrations apply -e dev database-dev

I'm not sure if this is how it's supposed to be done. It would be nice to be able to apply the same migrations first to the preview database.

@verokarhu verokarhu added the bug Something that isn't working label Dec 22, 2022
@rozenmd rozenmd added the d1 Relating to D1 label Dec 26, 2022
@rozenmd
Copy link
Contributor

rozenmd commented Dec 26, 2022

Hi @verokarhu - thanks for reporting this.

At the moment there's no nice way to deal with preview databases. The best workaround so far is as you've done - defining the preview database separately in wrangler.toml and manually running migrations on that database first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working d1 Relating to D1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants