问题
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!
回答1:
As luck would have it, Ruby on Rails v4.0.3
was released today. I did the following:
- Upgrade Rails
- deleted
db/migrate/schema.rb
- Delete all 3 databases (dev, test, production)
- ran
rake db:setup
- ran
rake db:migrate
- Looked at the new
db/migrate/schema.rb
to make sure it was OK - 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!
回答2:
It may be your migration that specifies each column to be array
来源:https://stackoverflow.com/questions/21868939/why-are-all-of-my-tables-in-rails-4-postgres-being-created-with-dimension-of-1