Rails Migration to make a column null => true

I had originally created a table with column as

t.string   "email",  :default => "", :null => false

The requirement has changed and now I need to allow email to be null. How can I write a migration to make :null => true

Answers


Try:

change_column :table_name, :email, :string, :null => true

I could not get the above solution to work with Active Record 4.0.8 and Postgresql 9.3

However change_column_null worked perfectly.

change_column_null :users, :email, true

The reverse has a nice option to update existing records (but not set the default) when null is not allowed.


Need Your Help

Checking if a postgresql table exists under python (and probably Psycopg2)

python postgresql psycopg2

How can I determine if a table exists using the Psycopg2 Python library? I want a true or false boolean.

Limit number of threads in numpy

python multithreading numpy

It seems that my numpy library is using 4 threads, and setting OMP_NUM_THREADS=1 does not stop this.