Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
f4f66107
Commit
f4f66107
authored
Aug 02, 2012
by
Dave Lawrence
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 756953 - Dependencies table should have unique index so that duplicate entries are blocked
r/a=LpSolit
parent
c6e47461
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
1 deletion
+30
-1
Schema.pm
Bugzilla/DB/Schema.pm
+2
-1
DB.pm
Bugzilla/Install/DB.pm
+28
-0
No files found.
Bugzilla/DB/Schema.pm
View file @
f4f66107
...
...
@@ -416,7 +416,8 @@ use constant ABSTRACT_SCHEMA => {
DELETE
=>
'CASCADE'
}},
],
INDEXES
=>
[
dependencies_blocked_idx
=>
[
'blocked'
],
dependencies_blocked_idx
=>
{
FIELDS
=>
[
qw(blocked dependson)
],
TYPE
=>
'UNIQUE'
},
dependencies_dependson_idx
=>
[
'dependson'
],
],
},
...
...
Bugzilla/Install/DB.pm
View file @
f4f66107
...
...
@@ -694,6 +694,9 @@ sub update_table_definitions {
# 2012-07-24 dkl@mozilla.com - Bug 776982
_fix_longdescs_primary_key
();
# 2012-08-02 dkl@mozilla.com - Bug 756953
_fix_dependencies_dupes
();
################################################################
# New --TABLE-- changes should go *** A B O V E *** this point #
################################################################
...
...
@@ -3725,6 +3728,31 @@ sub _fix_longdescs_primary_key {
}
}
sub
_fix_dependencies_dupes
{
my
$dbh
=
Bugzilla
->
dbh
;
my
$blocked_idx
=
$dbh
->
bz_index_info
(
'dependencies'
,
'dependencies_blocked_idx'
);
if
(
$blocked_idx
&&
scalar
@
{
$blocked_idx
->
{
'FIELDS'
}}
<
2
)
{
# Remove duplicated entries
my
$dupes
=
$dbh
->
selectall_arrayref
(
"
SELECT blocked, dependson, COUNT(*) AS count
FROM dependencies "
.
$dbh
->
sql_group_by
(
'blocked, dependson'
)
.
"
HAVING COUNT(*) > 1"
,
{
Slice
=>
{}
});
print
"Removing duplicated entries from the 'dependencies' table...\n"
if
@$dupes
;
foreach
my
$dupe
(
@$dupes
)
{
$dbh
->
do
(
"DELETE FROM dependencies
WHERE blocked = ? AND dependson = ?"
,
undef
,
$dupe
->
{
blocked
},
$dupe
->
{
dependson
});
$dbh
->
do
(
"INSERT INTO dependencies (blocked, dependson) VALUES (?, ?)"
,
undef
,
$dupe
->
{
blocked
},
$dupe
->
{
dependson
});
}
$dbh
->
bz_drop_index
(
'dependencies'
,
'dependencies_blocked_idx'
);
$dbh
->
bz_add_index
(
'dependencies'
,
'dependencies_blocked_idx'
,
{
FIELDS
=>
[
qw(blocked dependson)
],
TYPE
=>
'UNIQUE'
});
}
}
1
;
__END__
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment