I've seen a few questions (namely this one) here on SO about adding a default boolean value to an existing column. So I tried the change_column
suggestion but I mustn't be doing it right.
I tried:
$ change_column :profiles, :show_attribute, :boolean, :default => true
Which returns -bash: change_column: command not found
I then ran:
$ rails g change_column :profiles, :show_attribute, :boolean, :default => true
...and
$ rails change_column :profiles, :show_attribute, :boolean, :default => true
Then ran rake db:migrate
, but the value for :show_attribute
remained nil
. In the question I referenced above it says in PostgreSQL you need to update it manually. Since I'm using PostgreSQL I added the following in my create_profiles
migration:
t.boolean :show_attribute, :default => true
Can someone tell me what I'm doing wrong here?