Search code examples
ruby-on-railspostgresqlruby-on-rails-4rails-postgresql

Why are all of my tables in Rails 4/Postgres being created with "dimension" of 1?


I'm running into a LOT of problems just trying to do basic model generations and migrations in Rails 4 with Postgres. I have the pg gem installed, version 0.17.1.

In the beginning, I couldn't even run migrations without errors, because the schema_migrations table was created with the version column having a dimension of 1. Once I manually changed it to zero, it worked fine.

Now, if I look at all of the migrations that resulted from me using the Rails model generator, I see that every single column, with the exception of the id column in each table, was created with dimension of 1.

Is there some default setting I need to change? Is this somehow correct and I am messing up something else? This is my first Rails 4 project, so I'm just trying to figure out why it would want all of those columns to default to an Array.

Here is one of my migration files:

class CreateCatalogs < ActiveRecord::Migration
  def change
    create_table :catalogs do |t|
      t.string :name
      t.text :description
      t.string :schema_name
      t.string :catalog_type
      t.boolean :billable

      t.timestamps
    end
  end
end

And this is from schema.rb:

create_table "catalogs", force: true do |t|
  t.string   "name",         array: true
  t.text     "description",  array: true
  t.string   "schema_name",  array: true
  t.string   "catalog_type", array: true
  t.boolean  "billable",     array: true
  t.datetime "created_at",   array: true
  t.datetime "updated_at",   array: true
end

What in the heck!


Solution

  • As luck would have it, Ruby on Rails v4.0.3 was released today. I did the following:

    1. Upgrade Rails
    2. deleted db/migrate/schema.rb
    3. Delete all 3 databases (dev, test, production)
    4. ran rake db:setup
    5. ran rake db:migrate
    6. Looked at the new db/migrate/schema.rb to make sure it was OK
    7. ran rake db:test:prepare

    Sure enough, the problem is fixed in this new release. I couldn't find a record of the problem anywhere! It's been an issue for a few weeks. Anyway, fixed!