You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
can't migrate table "table_1" since adding the new PK column "new_pk_column" is not supported. Try dropping this table
65
+
can't migrate table "table_2" since changing the type of column "age" from "integer" to "text" is not supported. Try dropping this column for this table
66
+
can't migrate table "table_2" since changing the type of column "created_at" from "text" to "timestamp" is not supported. Try dropping this column for this table
67
+
68
+
To force a migration add "migrate_mode: forced" to your destination spec`,
can't migrate table "table_1" since adding the new PK column "new_pk_column" is not supported. Try dropping this table
128
-
can't migrate table "table_2" since changing the type of column "age" from "integer" to "text" is not supported. Try dropping this column for this table
129
-
can't migrate table "table_2" since changing the type of column "created_at" from "text" to "timestamp" is not supported. Try dropping this column for this table
errors=append(errors, fmt.Sprintf("can't migrate table %q since adding the new PK column %q is not supported. Try dropping this table", tableChange.table.Name, colChange.name))
161
+
messages=append(messages, migrationMessage{
162
+
err: fmt.Sprintf("can't migrate table %q since adding the new PK column %q is not supported. Try dropping this table", tableChange.table.Name, colChange.name),
163
+
info: fmt.Sprintf("table %q will be dropped and recreated", tableChange.table.Name),
164
+
})
141
165
// no need to report other errors as the user needs to drop the table altogether
errors=append(errors, fmt.Sprintf("can't migrate table %q since changing the type of column %q from %q to %q is not supported. Try dropping this column for this table", tableChange.table.Name, colChange.name, colChange.oldType, colChange.newType))
169
+
messages=append(messages, migrationMessage{
170
+
err: fmt.Sprintf("can't migrate table %q since changing the type of column %q from %q to %q is not supported. Try dropping this column for this table", tableChange.table.Name, colChange.name, colChange.oldType, colChange.newType),
171
+
info: fmt.Sprintf("column %q of table %q will be dropped and recreated", colChange.name, tableChange.table.Name),
172
+
})
146
173
}
147
174
}
148
175
}
149
-
returnerrors
176
+
returnmessages
150
177
}
151
178
152
179
// This is the responsibility of the CLI of the client to lock before running migration
returnfmt.Errorf("failed to migrate schema:\n%s\n\nTo force a migration add \"migrate_mode: %s\" to your destination spec", strings.Join(migrationMessages.Errors(), "\n"), specs.MigrateModeForced.String())
// If this is a new PK column we need to drop the table
212
+
ifcolChange.new&&colChange.newPk {
213
+
c.logger.Debug().Str("table", table.Name).Str("column", colChange.name).Msg("New column is a primary key, dropping and adding table since in forced migrate mode")
214
+
sql:="drop table if exists \""+tableName+"\""
215
+
if_, err:=c.db.Exec(sql); err!=nil {
216
+
returnfmt.Errorf("failed to drop table %s: %w", tableName, err)
c.logger.Debug().Str("table", table.Name).Str("column", colChange.name).Msg("Existing column type changed, dropping and adding column since in forced migrate mode")
234
+
sql:="alter table "+tableName+" drop column "+columnName
235
+
if_, err:=c.db.Exec(sql); err!=nil {
236
+
returnfmt.Errorf("failed to drop column %s on table %s: %w", columnName, tableName, err)
0 commit comments