-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Document using strapi instance for migrations #2085
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Thanks, @nc1z. |
All good @pwizla, appreciate the review 😃 From what I see, the docs don't advise against other approaches besides But let's see what derrick says, just sharing my opinion here since our team used strapi services as a quick way to reuse logic in our migrations without needing to build tables from scratch (especially when they have complex relations). |
This makes sense to me, the transaction thing won't be a problem afaik in Strapi 5 with the document service replacing the entity service and to my knowledge the docsrv will wrap everything in a transaction by default. Typically you wouldn't use the migrations for normal CRUD operations just db schema modifications or something but it will work for both. |
might result in data loss so the highest-level of callout is required Co-authored-by: Pierre Wizla <[email protected]>
Co-authored-by: Pierre Wizla <[email protected]>
Exciting stuff in Strapi 5 I see! 😄 Yeah in our case we had to create/migrate some tables, relations and sync content localizations for several environments including prod, so we figured using our service with Cool, @pwizla I'll leave you to decide if we want to merge, I'd think it's useful for v4 since most existing systems will still be on there for awhile. I've cleaned up according to your comments. Cheers 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good to me
Thanks for the insightful discussion, @derrickmehaffy and @nc1z! The PR is now approved, merged, should be live on docs.strapi.io in a few minutes, and will be mentioned in the next weekly snapshot release. |
What does it do?
Updated documentation for developers that decide to use
strapi
instead ofknex
to perform data migrations.Why is it needed?
Often developers may want to use their custom strapi service methods to perform migrations.
Important
This serves as a caution for new Strapi developers who might overlook the lack of atomicity when using the
strapi
instance, unlikeknex
, which operates within a transaction state by default when received in theup()
function.Source: this happened to my team😄
Related issue(s)/PR(s)
N/A