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

Updated DumpSqlCommand to compare against existing database #21

Merged
merged 4 commits into from
Jul 6, 2023

Conversation

Steveb-p
Copy link
Contributor

@Steveb-p Steveb-p commented Jul 5, 2023

Question Answer
JIRA issue N/A
Type improvement
Target Ibexa version v4.6
BC breaks no

This PR makes it so that schema comparison is executed against current database.

Checklist:

  • Provided PR description.
  • Tested the solution manually.
  • Provided automated test coverage.
  • Checked that target branch is set correctly (main for features, the oldest supported for bugs).
  • Ran PHP CS Fixer for new PHP code (use $ composer fix-cs).
  • Asked for a review (ping @ibexa/engineering).

@konradoboza konradoboza requested a review from a team July 5, 2023 10:07
Copy link
Member

@alongosz alongosz left a comment

Choose a reason for hiding this comment

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

TBH I would prefer some sort of flexibility - being able to both generate dump from the schema file and as a diff.

There's also an issue with Comparator itself - it always shows some changes, even though it shouldn't. For example, on the latest commerce 4.6.x-dev I'm getting the following results when executing the command without file argument: https://gist.github.com/alongosz/e1a3d95a40f819c3c46f7b3781f75622
Moreover when I tried to create custom schema file which defines app_my_table relation, I got the following result: https://gist.github.com/alongosz/8ddceb3d8cf31f16ad6f0d75d97ad493

Those were the reasons I've never introduced schema diff & easy upgrade when working on this package. It's very unstable.

@alongosz alongosz requested a review from a team July 5, 2023 10:43
@Steveb-p
Copy link
Contributor Author

Steveb-p commented Jul 5, 2023

@alongosz I would never advocate using this tool to perform an "easy upgrade". The main purpose of it is to generate a list of potential SQL commands, just like doctrine:schema:update --dump-sql command does. An engineer can then use this to check if all his schema changes are included in a proper SQL upgrade script.

The reason why it is unstable are differences in metadata provided by database vendors and the fact that we are already behind in DBAL v3 adoption. When checking their implementation in DBAL I've already noticed a few changes.

Changed in c08028e to allow both current database comparison and straight up schema generation from scratch.

@alongosz
Copy link
Member

alongosz commented Jul 5, 2023

@alongosz I would never advocate using this tool to perform an "easy upgrade". The main purpose of it is to generate a list of potential SQL commands, just like doctrine:schema:update --dump-sql command does. An engineer can then use this to check if all his schema changes are included in a proper SQL upgrade script.

@Steveb-p Do you think then that maybe it's worth to add a warning at the beginning of the execution? Something about making database backup and reviewing the script before applying it. I already can imagine people trying to use it, trusting it's a complete feature with correct output.

I was a bit reluctant to suggest that because without it you could stream the output directly to dbms sql interpreter mysql < $(php ...), but given the nature of the changes, maybe we shouldn't encourage people to do it?

The reason why it is unstable are differences in metadata provided by database vendors and the fact that we are already behind in DBAL v3 adoption. When checking their implementation in DBAL I've already noticed a few changes.

👌

Changed in c08028e to allow both current database comparison and straight up schema generation from scratch.

👍

@sonarcloud
Copy link

sonarcloud bot commented Jul 5, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@alongosz alongosz requested a review from a team July 5, 2023 15:58
@Steveb-p Steveb-p merged commit 8e8defd into main Jul 6, 2023
13 checks passed
@Steveb-p Steveb-p deleted the dump-sql-current branch July 6, 2023 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants