这是indexloc提供的服务,不要输入任何密码
Skip to content

Db migrations fail with the refinery4-compatible branch matho-update #171

@jussihirvi

Description

@jussihirvi

I installed this gem for my refinerycms 4.0.3 app (with Rails 5.1) from the matho-update branch:

gem 'refinerycms-news', github: 'refinery/refinerycms-news', branch: 'matho-update'

In general, it was a good experience. However, the first migration failed with a message:

== 20200915155938 CreateNewsItems: migrating ==================================
rails aborted!
StandardError: An error has occurred, all later migrations canceled:

[FriendlyId] You need to translate the 'slug' field with Mobility (add 'translates :slug' in your model 'Refinery::News::Item')
/usr/local/rvm/gems/ruby-2.5.7@refinery403/gems/friendly_id-mobility-0.5.4/lib/friendly_id/mobility.rb:35:in `advise_against_untranslated_model'

In fact the model already contains translates :slug. I checked that by overriding the model first.

Anyway, I could run the migrations successfully after temporarily commenting out the function advise_against_untranslated_model in the friendly_id gem.

First I thought the error is raised because the field slug is not yet added to the table in this first migration, but only in a later migration. But it is not that simple. I rolled back all ten migrations, added the field slugto the create tablestatement of the first migration, and tried to migrate again. Still I got the same error.

BTW, in the rollback of the create table migration, ::Refinery::UserPlugin was not found, and also this gives an error (because delete_all does not take parameters):

::Refinery::Page.delete_all :link_url => "/news"

So I edited it to

::Refinery::Page.where(link_url: "/news").delete_all

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions