-
Notifications
You must be signed in to change notification settings - Fork 615
add addMissingSchemaFields task #5101
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
base: main
Are you sure you want to change the base?
Conversation
…ation * main: (23 commits) PRO-8538: fix layout bug in mobile breakpoint preview that causes tiny collapsed columns (#5127) give color button a testable data attr (#5124) PRO-8530 autodetect ES bundles (#5120) Emphasize but unfocus in layout mode (#5125) Simplify layout max width (#5123) max width, anchors, labels (#5122) refactor and inject admin UI styles for layout (#5116) Color field swatches (#5118) Pro 8285 login case insensitive (#5100) fix paste bug (#5119) Implement change outlined on Discord (#5117) PRO-8374: Mute tooltip when edit is disabled (#5114) fix sticky when controls are disabled (#5115) enable logout and whoami routes if localLogin is false (#5098) add locale picker (#5090) enforce empty state font (#5113) sticky controls (#5106) Layout widget icon (#5112) Feature layout widget (#5031) PRO-8435: log what widget type was missing (#5110) ...
|
|
||
| ### Fixes | ||
|
|
||
| ## UNRELEASED |
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.
Recreating the section because this is not part of today's release, easier for me to handle future conflict.
boutell
left a comment
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.
Minor change request
| // Perform the actual migrations. Implementation of | ||
| // the @apostrophecms/migration:migrate task | ||
| async migrate(options) { | ||
| await self.emit('before'); |
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.
You should skip this line too, even though it means your task will have to explicitly call addMissingSchemaFields.
This is appropriate because:
- We used the
beforehook to implementaddMissingSchemaFields, which is a special kind of migration - Other people and other modules will likely do the same thing
- Michelin doesn't want anything else that smells like a migration at all to happen in this task.
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.
Regarding the following code
await self.apos.lock.withLock('@apostrophecms/migration:migrate', async () => {
await self.apos.migration.migrate(self.argv);
// Inserts the global doc in the default locale if it does not exist;
// same for other singleton piece types registered by other modules
for (const apostropheModule of Object.values(self.modules)) {
if (self.instanceOf(apostropheModule, '@apostrophecms/piece-type') && apostropheModule.options.singletonAuto) {
await apostropheModule.insertIfMissing();
}
}
await self.apos.page.implementParkAllInDefaultLocale();
await self.apos.doc.replicate(); // emits beforeReplicate and afterReplicate events
// Replicate will have created the parked pages across locales if needed,
// but we may still need to reset parked properties
await self.apos.page.implementParkAllInOtherLocales();
});Should I skip all apostropheModule.insertIfMissing + page.implementParkAllInDefaultLocale, doc.replicate & page.implementParkAllInOtherLocales too?
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.
Yes, that makes sense.
| await self.addMissingSchemaFields(); | ||
| } | ||
| }, | ||
| after: { |
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.
I see why you did this, but previously, these "requirements" were guaranteed to come last, even after the after event. And changing that is an unnecessary risk.
So, please make them individual handlers on a new requirements event which is fired after the after event has been safely awaited.
| // This is the right time to park pages, for instance, because the | ||
| // database is guaranteed to be in a stable state, whether because the | ||
| // site is new or because migrations ran successfully. | ||
| await self.emit('after'); |
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.
Emit a new requirements event "after after" 😄
Summary
Adds
@apostrophecms/migration:add-missing-schema-fieldstaskWhat are the specific steps to test this change?
@apostrophecms/migration:add-missing-schema-fieldsand@apostrophecms/migration:migratetasks maybe.What kind of change does this PR introduce?
(Check at least one)
Make sure the PR fulfills these requirements:
If adding a new feature without an already open issue, it's best to open a feature request issue first and wait for approval before working on it.
Other information: