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

wrong number of arguments on db:migrate #276

Closed
Chavret opened this issue Dec 20, 2017 · 1 comment
Closed

wrong number of arguments on db:migrate #276

Chavret opened this issue Dec 20, 2017 · 1 comment

Comments

@Chavret
Copy link

Chavret commented Dec 20, 2017

Hi first of all thanks for the gem ! I'm having an issue while trying to transform my DB (PostGreSQL) into PostGis adapter DB.
We have a lot of data in production and we need our migration to run good
I got this error when I run my migrations:

== 20171002160426 CreateMediaImagings: migrating ==============================
-- create_table(:media_imagings)
   -> 0.0408s
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

wrong number of arguments (given 3, expected 4..7)
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-postgis-adapter-3.1.5/lib/active_record/connection_adapters/postgis/schema_statements.rb:19:in `new_column'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/attributes.rb:124:in `block in add_user_provided_columns'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/attributes.rb:123:in `each'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/attributes.rb:123:in `map'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/attributes.rb:123:in `add_user_provided_columns'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/attribute_decorators.rb:28:in `add_user_provided_columns'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/attributes.rb:93:in `columns'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/attributes.rb:98:in `columns_hash'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/querying.rb:41:in `find_by_sql'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bullet-5.6.1/lib/bullet/active_record42.rb:24:in `find_by_sql'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/relation.rb:639:in `exec_queries'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/association_relation.rb:32:in `exec_queries'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/relation.rb:515:in `load'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/relation.rb:243:in `to_a'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bullet-5.6.1/lib/bullet/active_record42.rb:67:in `to_a'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/associations/collection_association.rb:434:in `get_records'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/associations/collection_association.rb:449:in `find_target'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/associations/collection_association.rb:392:in `load_target'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bullet-5.6.1/lib/bullet/active_record42.rb:177:in `load_target'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/associations/collection_proxy.rb:45:in `load_target'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/associations/collection_proxy.rb:945:in `to_ary'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/relation/delegation.rb:46:in `map'
/Users/glorian/code/Chavret/publidata-backend-2/publidata-backend/app/models/concerns/elasticsearch/methods.rb:25:in `maintainers_json'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activemodel-4.2.5/lib/active_model/serialization.rb:110:in `block in serializable_hash'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activemodel-4.2.5/lib/active_model/serialization.rb:110:in `each'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activemodel-4.2.5/lib/active_model/serialization.rb:110:in `serializable_hash'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/serialization.rb:17:in `serializable_hash'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activemodel-4.2.5/lib/active_model/serializers/json.rb:99:in `as_json'
/Users/glorian/code/Chavret/publidata-backend-2/publidata-backend/app/models/concerns/elasticsearch/searchable_medias.rb:197:in `as_indexed_json'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/elasticsearch-model-0.1.9/lib/elasticsearch/model.rb:108:in `as_indexed_json'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/elasticsearch-model-0.1.9/lib/elasticsearch/model/adapters/active_record.rb:108:in `block in __transform'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/elasticsearch-model-0.1.9/lib/elasticsearch/model/importing.rb:144:in `block in __batch_to_bulk'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/elasticsearch-model-0.1.9/lib/elasticsearch/model/importing.rb:144:in `map'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/elasticsearch-model-0.1.9/lib/elasticsearch/model/importing.rb:144:in `__batch_to_bulk'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/elasticsearch-model-0.1.9/lib/elasticsearch/model/importing.rb:126:in `block in import'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/elasticsearch-model-0.1.9/lib/elasticsearch/model/adapters/active_record.rb:103:in `block in __find_in_batches'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/relation/batches.rb:124:in `find_in_batches'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/querying.rb:9:in `find_in_batches'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/elasticsearch-model-0.1.9/lib/elasticsearch/model/proxy.rb:90:in `method_missing'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/elasticsearch-model-0.1.9/lib/elasticsearch/model/adapters/active_record.rb:102:in `__find_in_batches'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/elasticsearch-model-0.1.9/lib/elasticsearch/model/importing.rb:122:in `import'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/elasticsearch-model-0.1.9/lib/elasticsearch/model.rb:116:in `import'
/Users/glorian/code/Chavret/publidata-backend-2/publidata-backend/db/migrate/20171002160426_create_media_imagings.rb:21:in `data'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/migration_data-0.3.0/lib/migration_data/active_record/migration.rb:18:in `exec_migration_with_data'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:592:in `block (2 levels) in migrate'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/2.3.0/benchmark.rb:293:in `measure'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:591:in `block in migrate'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:590:in `migrate'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:768:in `migrate'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:998:in `block in execute_migration_in_transaction'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:1044:in `block in ddl_transaction'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/transactions.rb:220:in `transaction'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:1044:in `ddl_transaction'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:997:in `execute_migration_in_transaction'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:959:in `block in migrate'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:955:in `each'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:955:in `migrate'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:823:in `up'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/migration.rb:801:in `migrate'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `each'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:152:in `invoke_task'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `each'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:108:in `block in top_level'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:117:in `run_with_threads'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:102:in `top_level'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:80:in `block in run'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/application.rb:77:in `run'
/Users/glorian/code/Chavret/publidata-backend-2/publidata-backend/bin/rake:9:in `<top (required)>'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in `load'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in `block in load'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in `load'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Users/glorian/.rbenv/versions/2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
-e:1:in `<main>'

I saw that the issue is happening in schema_statement with the new_column method which takes 4 arguments but I give it only 3 but I don't figure out witch one I miss ?
"table_name, column_name, default, cast_type"
I'm not really understanding what this method does but she make any kind of save on any kind of object (ActiveRecordObject) break even if this object don't have geo_columns

My database.yml include:

adapter: postgis
encoding: unicode
postgis_extension: postgis
postgis_schema: public

I have an initializer named active-record-postgis-adapter including:

RGeo::ActiveRecord::SpatialFactoryStore.instance.tap do |config|
  config.default = RGeo::Geos.factory_generator
  config.register(RGeo::Geographic.spherical_factory(srid: 4326), geo_type: "point")
end

I have a migration before all the others:

execute("CREATE EXTENSION postgis;")

I think it should be ok .. What I'm missing ? All geodata works if I remove the gem then run my migrations and readd it after

@Chavret
Copy link
Author

Chavret commented Dec 20, 2017

Apparently it is a problem with jsonb attr_accessor in several of my classes, I saw an issue #267 with the same topic and it is still open so I could close this one to keep things right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant