Merge pull request #333 from github/no-unique-key

fix: bailing out on no PRIMARY/UNIQUE KEY
This commit is contained in:
Shlomi Noach 2016-12-13 11:35:34 +01:00 committed by GitHub
commit 322d897aeb
5 changed files with 12 additions and 3 deletions

View File

@ -95,7 +95,7 @@ func (this *Inspector) InspectTableColumnsAndUniqueKeys(tableName string) (colum
func (this *Inspector) InspectOriginalTable() (err error) {
this.migrationContext.OriginalTableColumns, this.migrationContext.OriginalTableUniqueKeys, err = this.InspectTableColumnsAndUniqueKeys(this.migrationContext.OriginalTableName)
if err == nil {
if err != nil {
return err
}
return nil

View File

@ -98,13 +98,11 @@ func TestTokenizeAlterStatement(t *testing.T) {
{
alterStatement := "add column t int, add column e enum('a','b','c')"
tokens, _ := parser.tokenizeAlterStatement(alterStatement)
log.Errorf("%#v", tokens)
test.S(t).ExpectTrue(reflect.DeepEqual(tokens, []string{"add column t int", "add column e enum('a','b','c')"}))
}
{
alterStatement := "add column t int(11), add column e enum('a','b','c')"
tokens, _ := parser.tokenizeAlterStatement(alterStatement)
log.Errorf("%#v", tokens)
test.S(t).ExpectTrue(reflect.DeepEqual(tokens, []string{"add column t int(11)", "add column e enum('a','b','c')"}))
}
}

View File

@ -0,0 +1,9 @@
drop table if exists gh_ost_test;
create table gh_ost_test (
i int not null,
ts timestamp default current_timestamp,
dt datetime,
key i_idx(i)
) auto_increment=1;
drop event if exists gh_ost_test;

View File

@ -0,0 +1 @@
No PRIMARY nor UNIQUE key found in table

View File

@ -0,0 +1 @@
--alter="add column v varchar(32)"