rolify: Directly inheriting from ActiveRecord::Migration is not supported
Rails: 5.1.0.beta1 Ruby: 2.4.0 Rolify: 5.1.0
This generated migration fails on this version of rails
class RolifyCreateRoles < ActiveRecord::Migration
def change
...
end
end
StandardError: An error has occurred, this and all later migrations canceled:
Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:
class RolifyCreateRoles < ActiveRecord::Migration[4.2]
/Users/brandoncordell/Code/dsk_group/db/migrate/20170307143104_rolify_create_roles.rb:1:in `<top (required)>'
/Users/brandoncordell/Code/dsk_group/bin/rails:9:in `require'
/Users/brandoncordell/Code/dsk_group/bin/rails:9:in `<top (required)>'
/Users/brandoncordell/Code/dsk_group/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
StandardError: Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:
class RolifyCreateRoles < ActiveRecord::Migration[4.2]
/Users/brandoncordell/Code/dsk_group/db/migrate/20170307143104_rolify_create_roles.rb:1:in `<top (required)>'
/Users/brandoncordell/Code/dsk_group/bin/rails:9:in `require'
/Users/brandoncordell/Code/dsk_group/bin/rails:9:in `<top (required)>'
/Users/brandoncordell/Code/dsk_group/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
Solution: I change class RolifyCreateRoles < ActiveRecord::Migration to class RolifyCreateRoles < ActiveRecord::Migration[5.0]
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 280
- Comments: 24 (1 by maintainers)
Commits related to this issue
- Explicitly state migration version As per https://github.com/RolifyCommunity/rolify/issues/444 — committed to azgul/company-api by azgul 7 years ago
- Fix deprecated migrations Add the Rails version specifier to active record migrations: `< ActiveRecord::Migration[5.0]` See: https://github.com/RolifyCommunity/rolify/issues/444 — committed to sealuzh/cloud-workbench by joe4dev 7 years ago
- fix migration generator for AR 5.x (#463) fixes #462, #444 and #466 — committed to RolifyCommunity/rolify by kirillseva 7 years ago
- Add `[4.2]` to all migration To prepapre for further rails 5 upgrades and remove migration deprecation warnings see [issue](https://github.com/RolifyCommunity/rolify/issues/444) — committed to ministryofjustice/Claim-for-Crown-Court-Defence by jsugarman 6 years ago
- Add `[4.2]` to all migration To prepapre for further rails 5 upgrades and remove migration deprecation warnings see [issue](https://github.com/RolifyCommunity/rolify/issues/444) — committed to ministryofjustice/Claim-for-Crown-Court-Defence by jsugarman 6 years ago
- Update to ruby 2.4.4, Rails 5.1.6 The migration files needed a small compatibility change... see: https://github.com/RolifyCommunity/rolify/issues/444 — committed to nikolas/forttree by nikolas 6 years ago
- Update to ruby 2.4.4, Rails 5.1.6 The migration files needed a small compatibility change... see: https://github.com/RolifyCommunity/rolify/issues/444 — committed to nikolas/forttree by nikolas 6 years ago
- Update to ruby 2.4.4, Rails 5.1.6 The migration files needed a small compatibility change... see: https://github.com/RolifyCommunity/rolify/issues/444 — committed to nikolas/forttree by nikolas 6 years ago
- Update to ruby 2.4.4, Rails 5.1.6 The migration files needed a small compatibility change... see: https://github.com/RolifyCommunity/rolify/issues/444 This also includes the following changes: *... — committed to nikolas/forttree by nikolas 6 years ago
- fixed migrate error reference https://github.com/RolifyCommunity/rolify/issues/444 — committed to tsui/swagger-codegen by tsui 6 years ago
- fix rolify bug https://github.com/RolifyCommunity/rolify/issues/444 — committed to dctalbot/readback by dctalbot 5 years ago
- Specify Rails release version in migration Directly inheriting from ActiveRecord::Migration is not supported Reference: https://github.com/RolifyCommunity/rolify/issues/444#issue-212450911 — committed to subhashsaran/tam-boon by subhashsaran 5 years ago
- Inherit from migration with a certain version https://github.com/RolifyCommunity/rolify/issues/444 — committed to sportngin/hubstats by emmahsax 5 years ago
- add rails version to migrations this fixes "Directly inheriting from ActiveRecord::Migration is not supported", during migrations, which seems to be introduced in rails 5. See https://github.com/Roli... — committed to RHoKAustralia/local-linguist-server by deleted user 4 years ago
- add ability to run locally in docker-compose (#36) * add docker compose, db init runs, migrate fails NOTE: I added require db details in database.yml for running in docker-compose. Probably don't... — committed to RHoKAustralia/local-linguist-server by deleted user 4 years ago
- Ubuntu 18.04 script for quickstart (#1173) — committed to postalserver/postal by blakethepatton 4 years ago
@jermaine Thanks. To prevent any which would already have a version tag, I changed your one-liner to the following:
Note the
$.@redtachyons When running this on OSX I get the following error:
...extra characters at the end of d commandTo get around this I had to add an empty string to sed.
This worked for me.
grep -rl "ActiveRecord::Migration" db | xargs sed -i "" "s/ActiveRecord::Migration/ActiveRecord::Migration[5.1]/g"Thanks for the tip, Here is one liner to do that in linux
thanks @brandoncordell
I just downgraded my rails to v5.0.5 and was able to run a migration without issues. I restored my app to use v5.1.3 and it started up.
Thank u for the solution @brandoncordell
@jermaine seems like that is a slight behavior change between Gnu sed and Bsd sed
Funny, but on 5.1.3 you still need add version to migration file.
Thanks @brandoncordell
Thank you @brandoncordell! I have been scratching my head all morning trying to figure that out!
*Rails 5.1.4.
Thanks @brandoncordell. This fixed it for me.
thanks
@brandoncordell – Thanks