Merge pull request #333 from github/no-unique-key
fix: bailing out on no PRIMARY/UNIQUE KEY
This commit is contained in:
commit
322d897aeb
@ -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
|
||||
|
@ -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')"}))
|
||||
}
|
||||
}
|
||||
|
9
localtests/no-unique-key/create.sql
Normal file
9
localtests/no-unique-key/create.sql
Normal 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;
|
1
localtests/no-unique-key/expect_failure
Normal file
1
localtests/no-unique-key/expect_failure
Normal file
@ -0,0 +1 @@
|
||||
No PRIMARY nor UNIQUE key found in table
|
1
localtests/no-unique-key/extra_args
Normal file
1
localtests/no-unique-key/extra_args
Normal file
@ -0,0 +1 @@
|
||||
--alter="add column v varchar(32)"
|
Loading…
Reference in New Issue
Block a user