Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue with upgrading metadata table in AWS Redshift #1231 #1256

Merged
merged 4 commits into from Apr 18, 2016

Conversation

nathanvick
Copy link
Contributor

This fixes the issue where upgrading the metadata table (from Flyway v3.2.1 to v4.0) failed, for at least some installations of AWS Redshift. Redshift does not support altering columns within a table. There are two common workarounds for this:

  • Copying data between temp columns: adding a temp column, copying data to the temp column, dropping the original column, adding the updated column, copying data back to the updated column, dropping the temp column
  • Copying data between temp tables: renaming the existing table, creating the updated table, copying data to the updated table, dropping the renamed table

This pull request changes the approach from "copying data between temp columns" to "copying data between temp tables" because the former approach requires a commit half way through the process, for some installations of Redshift.

nathanvick and others added 4 commits March 5, 2016 14:35
…failed

Flyway couldn't upgrade the metadata table, due to the following error:
"Amazon Invalid operation: cannot insert/update into table after dropping
non-nullable column"

This was caused by trying to remove the NOT NULL constraint on the version
column by adding/dropping a temp columan and copying the values. For somae
unknown reason, this works on some versions of Redshift, but not others.
The solution is just to rename the original table, create a new one, copy
the data, and drop the original table.
Redshift does not support indexes because it is a column-oriented
database. Instead data can be physically stored sorted, to improve
reading and sorting performance, based on the sort key.
….2.1 to 4.0 failed

When renaming a table, the schema should not be specified in the
new table name.
@axelfontaine axelfontaine added this to the Flyway 4.0.1 milestone Mar 24, 2016
@axelfontaine axelfontaine merged commit 5dc5b89 into flyway:master Apr 18, 2016
@axelfontaine
Copy link
Contributor

Thanks Nathan! Merged.

@axelfontaine
Copy link
Contributor

@nathanvick Could you please contact me by email at axel at boxfuse dot com ? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants