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

Add :migration_cast_version_column option #531

Merged
merged 3 commits into from
Jun 26, 2023

Conversation

whatyouhide
Copy link
Contributor

As discussed with @josevalim on Slack, this option allows us to skip the CAST(version AS int) that we do in migrations. Some databases, such as Cassandra, don't support CAST in DELETE queries, which migrations use when rolling back.

I'm sure the test could be improved, I just got something together that worked 🙃

default, Ecto casts this column as an `int` when reading or writing to the database
when running migrations. This behavior is there for legacy reasons, but if you
want to disable the `CAST`ing, you can set this option to `false`. You might want
to do that if you are using a database that doesn't support `CAST`ing in all queries.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can default to false and those on old databases can enable it again?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I remember now. Rails uses strings, we always used integer, and this was added for compatibility. Yeah, we can make this behaviour opt-in.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@josevalim awesome, nice! I've pushed changes to do that.

@josevalim josevalim merged commit 4d4405f into elixir-ecto:master Jun 26, 2023
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

@whatyouhide whatyouhide deleted the cast-version-migration branch June 26, 2023 15:35
whatyouhide added a commit to vinniefranco/exandra that referenced this pull request Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants