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

Fedora environment variable VERSION=0 causes Rails db migration reverting #530

Open
bullfrogliu opened this issue Mar 1, 2024 · 6 comments

Comments

@bullfrogliu
Copy link

Container platform

OCP 4

Version

Fedora

OS version of the container image

Fedora

Bugzilla, Jira

No response

Description

In Rails, it support this ENV when running migrations: bin/rails db:migrate VERSION=20080906120000

In Fedora images, it has VERSION=0 in the dockerfile which makes the target version 0 and reverting all the db migrations

Reproducer

No response

@jackorp
Copy link
Contributor

jackorp commented Mar 13, 2024

Thanks for the report, please could you share what are the versions of your Rails and ActiveRecord gems you use in the application?

@jackorp
Copy link
Contributor

jackorp commented Mar 13, 2024

Ok, I did some testing with Rails 6.1.7.7.

For a workaround it looks to be necessary to specify the variable VERSION as empty in command like so: VERSION= bin/rails db:migrate. Forcing VERSION to be empty either as showed or alternatively via export VERSION=. Rails 5 up to Rails 7 seem to have the required bits for this workaround to work, I have not tested all of them though.

Alternative workaround for when executed via shell (e.g. bash), unset the version like so: unset VERSION; bin/rails db:migrate.

@zmiklank zmiklank mentioned this issue Mar 27, 2024
@zmiklank
Copy link
Contributor

We plan to incorporate a fix to ruby 3.3 Fedora image.

@phracek
Copy link
Member

phracek commented May 16, 2024

Settings variable to 'VERSION=' or 'VERSION=""' cause a problems in our testing suite. See here: https://github.com/sclorg/container-common-scripts/blob/master/tag.sh#L35

it raises an exception like:

Tagged versions are: 3.3
-> Tagging image 'b69c9f006c16b7afebf3f6a50559143f962ae3c62cffcd90389e73f4169e6b02' as 'quay.io/fedora/ruby-33:' and 'quay.io/fedora/ruby-33:latest' and 'quay.io/fedora/ruby-33:fedora' and 'quay.io/fedora/ruby-33:20240516-acc810b'
Error: normalizing name "quay.io/fedora/ruby-33:": normalizing name "quay.io/fedora/ruby-33:": invalid reference format

We need to change this row https://github.com/sclorg/container-common-scripts/blob/master/tag.sh#L35
in case we want to setup VERSION to unset. It is used in labels here: https://github.com/sclorg/s2i-ruby-container/blob/master/3.3/Dockerfile.fedora#L28

@jackorp
Copy link
Contributor

jackorp commented May 16, 2024

Would renaming the VERSION variable in the Fedora containerfile be possible/reasonable? Something like "RUBY_IMAGE_VERSION="? From the scripts, it doesn't look like we expect usage outside of the container labels, but I havent investigated the usage in detail.

@pvalena
Copy link
Member

pvalena commented May 17, 2024

I think the variables should be either prefixed, or locally scoped.

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 a pull request may close this issue.

5 participants