Skip to content

initial rake db:migrate fails #31

Description

@RUN-CMD

Overview

Running rake db:migrate against an existing redshift db fails.

This is the first migration in the project, and it is failing to create the version column of the schema_migrations table.

After manually creating the schema_migrations table via an arbitrary redshift client, attempting to execute the migration below via rake db:migrate still fails.

Manually created schema_migrations table

CREATE TABLE schema_migrations (
  version text
);

Migration

cat db/migrate/20150827223207_create_users.rb 
class CreateUsers < ActiveRecord::Migration
  def change
    create_table "users", force: :cascade do |t|
      t.string   "name"
      t.string   "email",                  default: "", null: false
      t.string   "encrypted_password",     default: "", null: false
      t.string   "reset_password_token"
      t.datetime "reset_password_sent_at"
      t.datetime "remember_created_at"
      t.integer  "sign_in_count",          default: 0,  null: false
      t.datetime "current_sign_in_at"
      t.datetime "last_sign_in_at"
      t.string   "current_sign_in_ip"
      t.string   "last_sign_in_ip"
      t.datetime "created_at"
      t.datetime "updated_at"
    end
  end
end

Backtrace after manually creating schema_migrations (gem v0.2.0)

undefined method `array=' for #<ActiveRecord::ConnectionAdapters::Redshift::ColumnDefinition:0x007f8fde57aab0>
Did you mean?  Array/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord4-redshift-adapter-0.2.0/lib/active_record/connection_adapters/redshift/schema_definitions.rb:58:in `new_column_definition'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/schema_definitions.rb:267:in `column'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/schema_definitions.rb:115:in `primary_key'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord4-redshift-adapter-0.2.0/lib/active_record/connection_adapters/redshift/schema_definitions.rb:49:in `primary_key'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/schema_statements.rb:199:in `create_table'
... (etc) ...

Initial backtrace (gem v0.2.0)

rake aborted!
NoMethodError: undefined method `array=' for #<ActiveRecord::ConnectionAdapters::Redshift::ColumnDefinition:0x007fa57c275e88>
Did you mean?  Array
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord4-redshift-adapter-0.2.0/lib/active_record/connection_adapters/redshift/schema_definitions.rb:58:in `new_column_definition'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/schema_definitions.rb:267:in `column'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/schema_migration.rb:30:in `block in create_table'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/schema_statements.rb:202:in `create_table'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/schema_migration.rb:29:in `create_table'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/schema_statements.rb:819:in `initialize_schema_migrations_table'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:921:in `initialize'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:819:in `new'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:819:in `up'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:797:in `migrate'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/Users/sandwich/.gem/ruby/2.3.1/gems/bundler-1.13.6/lib/bundler/cli/exec.rb:74:in `load'
/Users/sandwich/.gem/ruby/2.3.1/gems/bundler-1.13.6/lib/bundler/cli/exec.rb:74:in `kernel_load'
/Users/sandwich/.gem/ruby/2.3.1/gems/bundler-1.13.6/lib/bundler/cli/exec.rb:27:in `run'
/Users/sandwich/.gem/ruby/2.3.1/gems/bundler-1.13.6/lib/bundler/cli.rb:332:in `exec'
/Users/sandwich/.gem/ruby/2.3.1/gems/bundler-1.13.6/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/sandwich/.gem/ruby/2.3.1/gems/bundler-1.13.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/Users/sandwich/.gem/ruby/2.3.1/gems/bundler-1.13.6/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
/Users/sandwich/.gem/ruby/2.3.1/gems/bundler-1.13.6/lib/bundler/cli.rb:20:in `dispatch'
/Users/sandwich/.gem/ruby/2.3.1/gems/bundler-1.13.6/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
/Users/sandwich/.gem/ruby/2.3.1/gems/bundler-1.13.6/lib/bundler/cli.rb:11:in `start'
/Users/sandwich/.gem/ruby/2.3.1/gems/bundler-1.13.6/exe/bundle:34:in `block in <top (required)>'
/Users/sandwich/.gem/ruby/2.3.1/gems/bundler-1.13.6/lib/bundler/friendly_errors.rb:100:in `with_friendly_errors'
/Users/sandwich/.gem/ruby/2.3.1/gems/bundler-1.13.6/exe/bundle:26:in `<top (required)>'
/Users/sandwich/.gem/ruby/2.3.1/bin/bundle:23:in `load'
/Users/sandwich/.gem/ruby/2.3.1/bin/bundle:23:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

Similar backtrace for v0.2.1 of this gem

NoMethodError: undefined method `array' for #<ActiveRecord::ConnectionAdapters::Redshift::ColumnDefinition:0x007fa91ac86098>
/Users/sandwich/src/pillpack/activerecord4-redshift-adapter/lib/active_record/connection_adapters/redshift/schema_statements.rb:27:in `type_for_column'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/schema_creation.rb:97:in `quote_value'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/schema_creation.rb:84:in `add_column_options!'
/Users/sandwich/src/pillpack/activerecord4-redshift-adapter/lib/active_record/connection_adapters/redshift/schema_statements.rb:21:in `add_column_options!'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/schema_creation.rb:33:in `visit_ColumnDefinition'
/Users/sandwich/src/pillpack/activerecord4-redshift-adapter/lib/active_record/connection_adapters/redshift/schema_statements.rb:8:in `visit_ColumnDefinition'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/schema_creation.rb:14:in `accept'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/schema_creation.rb:40:in `block in visit_TableDefinition'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/schema_creation.rb:40:in `map'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/schema_creation.rb:40:in `visit_TableDefinition'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/schema_creation.rb:14:in `accept'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/schema_statements.rb:208:in `create_table'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:661:in `block in method_missing'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:631:in `block in say_with_time'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:631:in `say_with_time'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:651:in `method_missing'
/Users/sandwich/src/playground/redshift-ruby-tutorial/db/migrate/20150827223207_create_users.rb:3:in `change'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:605:in `exec_migration'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:589:in `block (2 levels) in migrate'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:588:in `block in migrate'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:292:in `with_connection'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:587:in `migrate'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:764:in `migrate'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:994:in `block in execute_migration_in_transaction'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:1040:in `block in ddl_transaction'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `block in transaction'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/transaction.rb:184:in `within_new_transaction'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/transactions.rb:220:in `transaction'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:1040:in `ddl_transaction'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:993:in `execute_migration_in_transaction'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:955:in `block in migrate'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:951:in `each'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:951:in `migrate'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:819:in `up'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/migration.rb:797:in `migrate'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/tasks/database_tasks.rb:137:in `migrate'
/Users/sandwich/.gem/ruby/2.3.1/gems/activerecord-4.2.3/lib/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/Users/sandwich/.gem/ruby/2.3.1/gems/bundler-1.13.6/lib/bundler/cli/exec.rb:74:in `load'
/Users/sandwich/.gem/ruby/2.3.1/gems/bundler-1.13.6/lib/bundler/cli/exec.rb:74:in `kernel_load'
/Users/sandwich/.gem/ruby/2.3.1/gems/bundler-1.13.6/lib/bundler/cli/exec.rb:27:in `run'
/Users/sandwich/.gem/ruby/2.3.1/gems/bundler-1.13.6/lib/bundler/cli.rb:332:in `exec'
/Users/sandwich/.gem/ruby/2.3.1/gems/bundler-1.13.6/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Users/sandwich/.gem/ruby/2.3.1/gems/bundler-1.13.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/Users/sandwich/.gem/ruby/2.3.1/gems/bundler-1.13.6/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
/Users/sandwich/.gem/ruby/2.3.1/gems/bundler-1.13.6/lib/bundler/cli.rb:20:in `dispatch'
/Users/sandwich/.gem/ruby/2.3.1/gems/bundler-1.13.6/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
/Users/sandwich/.gem/ruby/2.3.1/gems/bundler-1.13.6/lib/bundler/cli.rb:11:in `start'
/Users/sandwich/.gem/ruby/2.3.1/gems/bundler-1.13.6/exe/bundle:34:in `block in <top (required)>'
/Users/sandwich/.gem/ruby/2.3.1/gems/bundler-1.13.6/lib/bundler/friendly_errors.rb:100:in `with_friendly_errors'
/Users/sandwich/.gem/ruby/2.3.1/gems/bundler-1.13.6/exe/bundle:26:in `<top (required)>'
/Users/sandwich/.gem/ruby/2.3.1/bin/bundle:23:in `load'
/Users/sandwich/.gem/ruby/2.3.1/bin/bundle:23:in `<main>'
Tasks: TOP => db:migrate

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions