yii2 icon indicating copy to clipboard operation
yii2 copied to clipboard

Migration & MySql Query addCheck() and dropCheck()

Open bobonov opened this issue 1 year ago • 5 comments

Q A
Is bugfix? ✔️
New feature?
Breaks BC?
Fixed issues #19817, #19819

bobonov avatar Jul 05 '23 10:07 bobonov

PR Summary

  • Check Constraint Management in Migration Class In the Migration file (framework/db/Migration.php), two new methods are introduced. The addCheck method is created to generate a SQL command that adds a rule - a check constraint, to an existing database table. Similarly, the dropCheck method is introduced to compose a SQL command for removing any check constraint from a database table.

  • Removal of Unsupported Methods in MySQL Query Builder In the MySQL Query Builder file (framework/db/mysql/QueryBuilder.php), addCheck and dropCheck methods are discarded. The motivation behind this action is that MySQL does not support these operations, hence removing them improves the overall robustness and reliability of this part of the system.

what-the-diff[bot] avatar Jul 05 '23 10:07 what-the-diff[bot]

Codecov Report

Attention: Patch coverage is 0% with 31 lines in your changes are missing coverage. Please review.

Project coverage is 60.49%. Comparing base (391997a) to head (bd73df5). Report is 1 commits behind head on master.

:exclamation: Current head bd73df5 differs from pull request most recent head 2ead4f3

Please upload reports for the commit 2ead4f3 to get more accurate results.

Files Patch % Lines
framework/db/mysql/Schema.php 0.00% 23 Missing :warning:
framework/db/Migration.php 0.00% 8 Missing :warning:
Additional details and impacted files
@@              Coverage Diff              @@
##             master   #19881       +/-   ##
=============================================
+ Coverage     18.65%   60.49%   +41.84%     
- Complexity    11379    11383        +4     
=============================================
  Files           430      430               
  Lines         37071    37103       +32     
=============================================
+ Hits           6915    22445    +15530     
+ Misses        30156    14658    -15498     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jul 11 '23 08:07 codecov[bot]

hi, @bobonov, would have time to apply the suggestions, to finish the PR,

Thks.

terabytesoftw avatar Sep 21 '23 14:09 terabytesoftw

Hi, add line in changelog,

Thks,

terabytesoftw avatar Oct 05 '23 15:10 terabytesoftw

@bobonov Thanks for the PR. Would you please work on the comments, notably change log entries, so that the PR can be merged?

mtangoo avatar Feb 15 '24 05:02 mtangoo

I think we need to enable MySQL tests for this feature:

https://github.com/yiisoft/yii2/blob/f2ea9be24225987b2acf2d6fdd2789e0a32b7fb0/tests/framework/db/mysql/CommandTest.php#L20

done.

terabytesoftw avatar May 18 '24 15:05 terabytesoftw

This PR needs to be updated, since for Yii2 to correctly support addCheck() and dropCheck() in MySQL, loadTableChecks() must be implemented for MySQL 8.0.16 or higher, so it is in progress.

terabytesoftw avatar May 18 '24 16:05 terabytesoftw

The PR title and changelog need to be updated too, since it does more than add/drop check

mtangoo avatar May 18 '24 20:05 mtangoo

Please if you can take a look, all the tests work,

Thks.

@rob006 @bizley @darkdef

terabytesoftw avatar May 18 '24 21:05 terabytesoftw

@rob006 @darkdef @rhertogh can you review this PR? Would like to see it merged before end of this week, if we can make that happen!

mtangoo avatar May 20 '24 08:05 mtangoo

Thanks everyone and especially @bobonov and @terabytesoftw for your work on the PR

mtangoo avatar May 22 '24 15:05 mtangoo