added tests to verify no false positives rename-column found

This commit is contained in:
Shlomi Noach 2016-11-29 11:08:35 +01:00
parent cb040b8bbf
commit 5119ea4d31
5 changed files with 19 additions and 1 deletions

View File

@ -229,7 +229,7 @@ func (this *Migrator) validateStatement() (err error) {
if this.parser.HasNonTrivialRenames() && !this.migrationContext.SkipRenamedColumns {
this.migrationContext.ColumnRenameMap = this.parser.GetNonTrivialRenames()
if !this.migrationContext.ApproveRenamedColumns {
return fmt.Errorf("gh-ost believes the ALTER statement renames columns, as follows: %v; as precation, you are asked to confirm gh-ost is correct, and provide with `--approve-renamed-columns`, and we're all happy. Or you can skip renamed columns via `--skip-renamed-columns`, in which case column data may be lost", this.parser.GetNonTrivialRenames())
return fmt.Errorf("gh-ost believes the ALTER statement renames columns, as follows: %v; as precaution, you are asked to confirm gh-ost is correct, and provide with `--approve-renamed-columns`, and we're all happy. Or you can skip renamed columns via `--skip-renamed-columns`, in which case column data may be lost", this.parser.GetNonTrivialRenames())
}
log.Infof("Alter statement has column(s) renamed. gh-ost finds the following renames: %v; --approve-renamed-columns is given and so migration proceeds.", this.parser.GetNonTrivialRenames())
}

View File

@ -0,0 +1,8 @@
drop table if exists gh_ost_test;
create table gh_ost_test (
id int auto_increment,
c1 int not null,
primary key (id)
) auto_increment=1;
drop event if exists gh_ost_test;

View File

@ -0,0 +1 @@
--alter="add column exchange double comment 'exchange rate used for pay in your own currency'"

View File

@ -0,0 +1,8 @@
drop table if exists gh_ost_test;
create table gh_ost_test (
id int auto_increment,
c1 int not null,
primary key (id)
) auto_increment=1;
drop event if exists gh_ost_test;

View File

@ -0,0 +1 @@
--alter="add column exchange_rate double comment 'change rate used for pay in your own currency'"