Bugzilla – Attachment 111712 Details for
Bug 18050
Missing constraint on aqbudgets.budget_period_id in aqbudgets
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18050: (follow-up) Force adding FK constraint
Bug-18050-follow-up-Force-adding-FK-constraint.patch (text/plain), 2.65 KB, created by
Katrin Fischer
on 2020-10-15 11:55:38 UTC
(
hide
)
Description:
Bug 18050: (follow-up) Force adding FK constraint
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2020-10-15 11:55:38 UTC
Size:
2.65 KB
patch
obsolete
>From 11e30bf21dc2ba400d1771cf6688be5fd0fe450c Mon Sep 17 00:00:00 2001 >From: Agustin Moyano <agustinmoyano@theke.io> >Date: Fri, 9 Oct 2020 15:14:26 -0300 >Subject: [PATCH] Bug 18050: (follow-up) Force adding FK constraint > >When there are inconsistent budget_period_id in aqbudgets this patch >creates the table _bug_18050_aqbudgets with the original data, then sets >the column to null and warns the user that there is inconsistent data. > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > .../atomicupdate/bug_18050_aqbudget_constraint.perl | 20 ++++++++++++++++++-- > 1 file changed, 18 insertions(+), 2 deletions(-) > >diff --git a/installer/data/mysql/atomicupdate/bug_18050_aqbudget_constraint.perl b/installer/data/mysql/atomicupdate/bug_18050_aqbudget_constraint.perl >index f110bad237..f978bdc6ba 100644 >--- a/installer/data/mysql/atomicupdate/bug_18050_aqbudget_constraint.perl >+++ b/installer/data/mysql/atomicupdate/bug_18050_aqbudget_constraint.perl >@@ -6,13 +6,29 @@ if( CheckVersion( $DBversion ) ) { > > |); > >+ my $message = ""; >+ >+ if($count_missing_budget->[0] > 0) { >+ $dbh->do(q{ >+ CREATE TABLE _bug_18050_aqbudgets AS >+ SELECT * FROM aqbudgets ab WHERE NOT EXISTS >+ (SELECT * FROM aqbudgetperiods abp WHERE abp.budget_period_id = ab.budget_period_id) >+ }); >+ >+ $dbh->do(q{ >+ UPDATE aqbudgets ab SET budget_period_id = NULL >+ WHERE NOT EXISTS >+ (SELECT * FROM aqbudgetperiods abp WHERE abp.budget_period_id = ab.budget_period_id) >+ }); >+ >+ $message = "There are $count_missing_budget->[0] funds in your database that are not linked to a valid budget. Setting invalid budget id (budget_period_id) to null. The table _bug_18050_aqbudgets was created with original data. Please check that table and place valid ids in aqbudget table as soon as possible." >+ } >+ > if ( !foreign_key_exists( 'aqbudgets', 'aqbudgetperiods_ibfk_1' ) && $count_missing_budget->[0] == 0 ) { > $dbh->do(q| > ALTER TABLE aqbudgets ADD CONSTRAINT `aqbudgetperiods_ibfk_1` FOREIGN KEY (`budget_period_id`) REFERENCES `aqbudgetperiods` (`budget_period_id`) ON UPDATE CASCADE ON DELETE CASCADE > |); > NewVersion( $DBversion, 18050, "Add FK constraint on aqbudgets.budget_period_id"); >- } elsif ( $count_missing_budget->[0] > 0 ) { >- NewVersion( $DBversion, 18050, "FK constraint on aqbudgets.budget_period_id couldn't be added. There are $count_missing_budget->[0] funds in your database that are not linked to a valid budget."); > } else { > NewVersion( $DBversion, 18050, "FK constraint on aqbudgets.budget already exists"); > } >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18050
:
110076
|
110078
|
110079
|
110080
|
110169
|
110170
|
110171
|
111429
|
111712
|
111713
|
111751
|
111752
|
111753
|
111754
|
111755
|
112529
|
112530