failing on DATETIME-to-TIMESTAMP conversion within chosen key

This commit is contained in:
Shlomi Noach 2016-10-14 09:33:53 +02:00
parent 7c22f25afa
commit 9ac468c97e
2 changed files with 10 additions and 0 deletions

View File

@ -146,6 +146,12 @@ func (this *Inspector) InspectOriginalAndGhostTables() (err error) {
} }
} }
for _, column := range this.migrationContext.UniqueKey.Columns.Columns() {
if this.migrationContext.MappedSharedColumns.HasTimezoneConversion(column.Name) {
return fmt.Errorf("No support at this time for converting a column from DATETIME to TIMESTAMP that is also part of the chosen unique key. Column: %s, key: %s", column.Name, this.migrationContext.UniqueKey.Name)
}
}
return nil return nil
} }

View File

@ -161,6 +161,10 @@ func (this *ColumnList) SetConvertDatetimeToTimestamp(columnName string, toTimez
this.GetColumn(columnName).timezoneConversion = &TimezoneConvertion{ToTimezone: toTimezone} this.GetColumn(columnName).timezoneConversion = &TimezoneConvertion{ToTimezone: toTimezone}
} }
func (this *ColumnList) HasTimezoneConversion(columnName string) bool {
return this.GetColumn(columnName).timezoneConversion != nil
}
func (this *ColumnList) String() string { func (this *ColumnList) String() string {
return strings.Join(this.Names(), ",") return strings.Join(this.Names(), ",")
} }