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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to share state of D1 and other products locally (workers and pages project)) #16572

Open
cloudcreatr opened this issue Aug 31, 2024 · 2 comments
Labels
content:new Request for new/missing content documentation Documentation edits product:d1 D1: https://developers.cloudflare.com/d1/ product:workers Related to Workers product

Comments

@cloudcreatr
Copy link
Contributor

Proposed changes

https://developers.cloudflare.com/workers/wrangler/api/#parameters-1
https://developers.cloudflare.com/d1/build-with-d1/local-development/#persist-data

Subject Matter

How to share D1 and other projects locally between different projects

Content Location

I have a mono repo setup and I had spend a quite some time to figure out how to share cloudflare D1 between different projects locally. Cloudflare D1 states, are unique to each project locally. It would be good if there's specific documentation saying how to do that. For example if you want to link pages project and workers projects locally with one D1 you have to use get platform proxy function in pages and use its persist option with directory path and also do the same with workers but difference use the same directory with command option in Wrangler to persist. But how should one mange migrations now for common shared D1 locally

https://developers.cloudflare.com/d1/reference/migrations/#wrangler-customizations
Here it's mentioned that we can change the migration directory, but in this part
https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases, it's not mentioned only that there's option to rename the migration folder. This inconsistent behaviour cab lead to a lot of delay..
I am using turbo repo, i have created a internal package that uses different migration folder for each D1 and persist the files to common directory, both workers and pages depends on it. Please make the changes. Thanks

Additional information

No response

@cloudcreatr cloudcreatr added content:new Request for new/missing content documentation Documentation edits labels Aug 31, 2024
@github-actions github-actions bot added product:d1 D1: https://developers.cloudflare.com/d1/ product:workers Related to Workers product labels Aug 31, 2024
@inerte
Copy link

inerte commented Sep 2, 2024

@cloudcreatr Maybe --persist-to works for you? As seen here cloudflare/workers-sdk#4755

@cloudcreatr
Copy link
Contributor Author

@cloudcreatr Maybe --persist-to works for you? As seen here cloudflare/workers-sdk#4755

As it does, but not for pages, where vite is used in local development. It would be good if they document that you have to use GetplatformProxy function to persist in development mode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content:new Request for new/missing content documentation Documentation edits product:d1 D1: https://developers.cloudflare.com/d1/ product:workers Related to Workers product
Projects
None yet
Development

No branches or pull requests