Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ensembl
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
ensembl
Commits
d4e22a57
Commit
d4e22a57
authored
18 years ago
by
Glenn Proctor
Browse files
Options
Downloads
Patches
Plain Diff
Added backing up of original attribute table
parent
3b9326c4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
misc-scripts/attribute_types/upload_attributes.pl
+30
-11
30 additions, 11 deletions
misc-scripts/attribute_types/upload_attributes.pl
with
30 additions
and
11 deletions
misc-scripts/attribute_types/upload_attributes.pl
+
30
−
11
View file @
d4e22a57
...
...
@@ -12,14 +12,15 @@ use IO::File;
use
FindBin
;
my
(
$host
,
$user
,
$pass
,
$port
,
@dbnames
,
$file
,
$release_num
);
GetOptions
(
"
host=s
",
\
$host
,
"
user=s
",
\
$user
,
"
pass=s
",
\
$pass
,
"
port=i
",
\
$port
,
"
file=s
",
\
$file
,
"
dbnames=s@
",
\
@dbnames
,
my
(
$host
,
$user
,
$pass
,
$port
,
@dbnames
,
$file
,
$release_num
,
$nobackup
);
GetOptions
(
"
host=s
",
\
$host
,
"
user=s
",
\
$user
,
"
pass=s
",
\
$pass
,
"
port=i
",
\
$port
,
"
file=s
",
\
$file
,
"
nobackup
",
\
$nobackup
,
"
dbnames=s@
",
\
@dbnames
,
"
release_num=i
",
\
$release_num
);
...
...
@@ -63,9 +64,12 @@ if($input ne 'yes') {
my
$attribs
=
read_attrib_file
(
$file
);
# if any attrib_types are loaded that are different from the file, a consistency problem
# if any attrib_types are loaded that are different from the file, a consistency problem
# is reported and the upload is not done.
for
my
$database
(
@dbnames
)
{
backup_attribute_types
(
$host
,
$user
,
$pass
,
$port
,
$database
)
if
(
!
$nobackup
);
if
(
check_consistency
(
$attribs
,
$database
,
$db
))
{
# consistent
$db
->
do
(
"
use
$database
"
);
...
...
@@ -118,7 +122,7 @@ sub repair {
"
on oat.code = at.code
"
.
"
where at.code is null
"
);
$db
->
do
(
"
insert into attrib_type( code, name, description)
"
.
"
select code, name, description
"
.
"
select code, name, description
"
.
"
from tmp_attrib_types
"
);
$ref
=
$db
->
selectall_arrayref
(
"
select code from tmp_attrib_types
"
);
...
...
@@ -183,7 +187,7 @@ sub check_consistency {
$db_codes
{
$arr
->
[
0
]
}
=
$arr
->
[
1
];
}
# check if any ids in the database colide with the file
# check if any ids in the database col
l
ide with the file
my
$consistent
=
1
;
for
my
$dbid
(
keys
%db_codes
)
{
if
(
!
exists
$file_codes
{
$dbid
}
||
...
...
@@ -223,6 +227,21 @@ sub read_attrib_file {
return
\
@rows
;
}
sub
backup_attribute_types
{
my
(
$host
,
$user
,
$pass
,
$port
,
$dbname
)
=
@_
;
unless
(
system
("
mysql -h
$host
-P
$port
-u
$user
-p
$pass
-N -e 'select * from attrib_type'
$dbname
>
$dbname
.attrib_type.backup; gzip -9 -f
$dbname
.attrib_type.backup
")
==
0
)
{
print
STDERR
"
Can't dump the original attrib_type table from
$dbname
for backup
\n
";
exit
1
;
}
else
{
print
STDERR
"
Original attrib_type table backed up in
$dbname
.attrib_type.backup
\n
";
}
}
sub
usage
{
GetOptions
(
"
host=s
",
\
$host
,
"
user=s
",
\
$user
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment