shioyama/friendly_id-mobility

Error due to unsupported/explicit after: :scope in migration

khalilgharbaoui opened this issue · 0 comments

This seems to be unsupported now and in any case its not strictly mandatory to explicitly define column position using after:.

add_column :friendly_id_slugs, :locale, :string, null: :false, after: :scope

Without specifying the position, the new column will be added at the end of the table by default. which is always after :scope

Suggestion: simply leaving it out of the generator template. i tested it and it works well without. see: #36

Error Details:

Ruby: 3.3.0
Rails: 7.1.3
Database adapter: postgresql

Unknown key: :after. Valid keys are: :limit, :precision, :scale, :default, :null, :collation, :comment, :primary_key, :if_exists, :if_not_exists, :array, :using, :cast_as, :as, :type, :enum_type, :stored

Trace:

** Execute db:migrate
== 20240217161147 AddLocaleToFriendlyIdSlugs: migrating =======================
-- add_column(:friendly_id_slugs, :locale, :string, {:null=>false})
   -> 0.0027s
-- change_table(:friendly_id_slugs)
bin/rails aborted!
StandardError: An error has occurred, this and all later migrations canceled: (StandardError)

Unknown key: :after. Valid keys are: :limit, :precision, :scale, :default, :null, :collation, :comment, :primary_key, :if_exists, :if_not_exists, :array, :using, :cast_as, :as, :type, :enum_type, :stored
/Users/khalil/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/activesupport-7.1.3/lib/active_support/core_ext/hash/keys.rb:52:in `block in assert_valid_keys'
/Users/khalil/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/activesupport-7.1.3/lib/active_support/core_ext/hash/keys.rb:50:in `each_key'
/Users/khalil/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/activesupport-7.1.3/lib/active_support/core_ext/hash/keys.rb:50:in `assert_valid_keys'
/Users/khalil/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/abstract/schema_definitions.rb:592:in `create_column_definition'
/Users/khalil/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/abstract/schema_definitions.rb:569:in `new_column_definition'
/Users/khalil/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/postgresql/schema_definitions.rb:275:in `new_column_definition'
/Users/khalil/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/postgresql/schema_statements.rb:426:in `build_change_column_definition'
/Users/khalil/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/postgresql/schema_statements.rb:1003:in `change_column_for_alter'
/Users/khalil/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/postgresql/schema_statements.rb:414:in `change_column'
/Users/khalil/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/abstract/schema_definitions.rb:790:in `change'
/Users/khalil/code/Furno/furno/db/migrate/20240217161147_add_locale_to_friendly_id_slugs.rb:5:in `block in change'