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
fix d&p regressions #8314
fix d&p regressions #8314
Conversation
petersg83
commented
Oct 13, 2020
- doesn't run d&p migration when a content-type is created
- rebuild tables if they were deleted in DB
Codecov Report
@@ Coverage Diff @@
## master #8314 +/- ##
=======================================
Coverage 33.19% 33.19%
=======================================
Files 1220 1220
Lines 13618 13618
Branches 1357 1357
=======================================
Hits 4521 4521
Misses 8212 8212
Partials 885 885
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
24743a4
to
cbc3bff
Compare
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.
Checking for definition change is good for feature level checks to do some mgiration for examples.
But table checks should also happen in createOrUpdateTable like before to check for columns in details.
This will decouple two different purposes and allow us to move the def diffing on a higher layer eventually.
packages/strapi-connector-bookshelf/lib/utils/store-definition.js
Outdated
Show resolved
Hide resolved
cbc3bff
to
3762fee
Compare
3762fee
to
e7028ab
Compare
const draftAndPublishMigrationWay = await getDraftAndPublishMigrationWay({ definition, ORM }); | ||
if (draftAndPublishMigrationWay === 'disable') { | ||
await migrateDraftAndPublish({ definition, ORM, way: 'disable' }); | ||
} | ||
|
||
// Update/create the tables in database | ||
await createOrUpdateTables({ ORM, loadedModel, definition, connection, model }); |
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 will want to run this before the D&P migration in case the schema is corrputed to prevent errors in the migration
); | ||
const changedAttributesResult = await Promise.all( | ||
attrNamesWithoutTimestamps.map(attributeName => | ||
didColumnDefinitionChange(attributeName, definition, ORM) |
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.
doing this for every attribute is going to be painful. can you fetch the definition only once
|
||
if (!columnExist) { | ||
columnsToAdd[columns[index]] = attribute; | ||
columnsToAdd[attributesNames[index]] = attribute; |
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 think we should refactor that bit of code to get the columnsTo add either using an async for loop or make it more functional. here are 2 examples https://repl.it/@alexandrebodin/WelllitFuzzyQuadrants#index.js
…deleted in DB Signed-off-by: Pierre Noël <petersg83@gmail.com>
Signed-off-by: Pierre Noël <petersg83@gmail.com>
3cdb6bc
to
d84284f
Compare
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.
LGTM