s2i-ruby-container icon indicating copy to clipboard operation
s2i-ruby-container copied to clipboard

Fedora environment variable VERSION=0 causes Rails db migration reverting

Open bullfrogliu opened this issue 11 months ago • 6 comments

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

bullfrogliu avatar Mar 01 '24 09:03 bullfrogliu

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

jackorp avatar Mar 13 '24 16:03 jackorp

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.

jackorp avatar Mar 13 '24 17:03 jackorp

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

zmiklank avatar Mar 27 '24 11:03 zmiklank