Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
khalilgharbaoui opened this issue Feb 17, 2024 · 0 comments · May be fixed by #36
Open

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

khalilgharbaoui opened this issue Feb 17, 2024 · 0 comments · May be fixed by #36

Comments

@khalilgharbaoui
Copy link

khalilgharbaoui commented Feb 17, 2024

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'
khalilgharbaoui added a commit to khalilgharbaoui/friendly_id-mobility that referenced this issue Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant