spree-contrib / spree_editor

Rich text editor for Spree with Image and File uploading in-place.
http://guides.spreecommerce.org
BSD 3-Clause "New" or "Revised" License
112 stars 183 forks source link

CKEditor - Migrations not supported #128

Open kinduff opened 6 years ago

kinduff commented 6 years ago

Hello, I'm adding this gem to a Spree 3-4-stable installation.

$ ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin15]
$ rails -v
Rails 5.1.4 

And in my Gemfile:

gem 'spree_editor', github: 'spree-contrib/spree_editor'

All good during installation until I arrive to the following step from the README.

$ rails g ckeditor:install --orm=active_record --backend=paperclip && rake db:migrate

This command fails returning the following content:

$ rails g ckeditor:install --orm=active_record --backend=paperclip && rake db:migrate
Running via Spring preloader in process 55518
      create  config/initializers/ckeditor.rb
       route  mount Ckeditor::Engine => '/ckeditor'
      create  app/models/ckeditor/asset.rb
      create  app/models/ckeditor/picture.rb
      create  app/models/ckeditor/attachment_file.rb
      create  db/migrate/20171024133830_create_ckeditor_assets.rb
rake aborted!
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 CreateCkeditorAssets < ActiveRecord::Migration[4.2]
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:525:in `inherited'
/Users/kinduff/www/biutiko-store-new/db/migrate/20171024133830_create_ckeditor_assets.rb:1:in `<top (required)>'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `block in require'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:962:in `load_migration'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:958:in `migration'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:953:in `disable_ddl_transaction'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:1305:in `use_transaction?'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:1297:in `ddl_transaction'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:1229:in `execute_migration_in_transaction'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:1201:in `block in migrate_without_lock'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:1200:in `each'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:1200:in `migrate_without_lock'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:1148:in `block in migrate'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:1317:in `with_advisory_lock'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:1148:in `migrate'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:1007:in `up'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:985:in `migrate'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:171:in `migrate'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/rake-12.1.0/exe/rake:27:in `<top (required)>'
/Users/kinduff/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in `eval'
/Users/kinduff/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in `<main>'
StandardError: Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:

  class CreateCkeditorAssets < ActiveRecord::Migration[4.2]
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:525:in `inherited'
/Users/kinduff/www/biutiko-store-new/db/migrate/20171024133830_create_ckeditor_assets.rb:1:in `<top (required)>'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `block in require'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:962:in `load_migration'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:958:in `migration'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:953:in `disable_ddl_transaction'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:1305:in `use_transaction?'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:1297:in `ddl_transaction'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:1229:in `execute_migration_in_transaction'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:1201:in `block in migrate_without_lock'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:1200:in `each'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:1200:in `migrate_without_lock'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:1148:in `block in migrate'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:1317:in `with_advisory_lock'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:1148:in `migrate'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:1007:in `up'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/migration.rb:985:in `migrate'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/tasks/database_tasks.rb:171:in `migrate'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/activerecord-5.1.4/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
/Users/kinduff/.rvm/gems/ruby-2.4.0/gems/rake-12.1.0/exe/rake:27:in `<top (required)>'
/Users/kinduff/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in `eval'
/Users/kinduff/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

I find this error kind of weird because I've been installing other gems with migrations with the same pattern and I've not encounter any issue during install.

Any workarounds or guidance about how to install successfully?

kinduff commented 6 years ago

Update I was able to work around it by adding manually [4.2] to the CKEditor migration that was added to my project at db/migrate/20171024133830_create_ckeditor_assets.rb.