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

fix d&p regressions #8314

Merged
merged 3 commits into from Oct 20, 2020
Merged

fix d&p regressions #8314

merged 3 commits into from Oct 20, 2020

Conversation

petersg83
Copy link
Contributor

  • doesn't run d&p migration when a content-type is created
  • rebuild tables if they were deleted in DB

@codecov
Copy link

codecov bot commented Oct 13, 2020

Codecov Report

Merging #8314 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           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           
Flag Coverage Δ
#front 24.72% <ø> (ø)
#unit 54.45% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fad9fda...d84284f. Read the comment docs.

@petersg83 petersg83 marked this pull request as ready for review October 13, 2020 13:30
@petersg83 petersg83 requested a review from a team as a code owner October 13, 2020 13:30
Copy link
Member

@alexandrebodin alexandrebodin left a 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.

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 });
Copy link
Member

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)
Copy link
Member

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;
Copy link
Member

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>
Signed-off-by: Pierre Noël <petersg83@gmail.com>
Copy link
Member

@alexandrebodin alexandrebodin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Issue reporting a bug source: core:database Source is core/database package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants