Petros Kalas
Petros Kalas

Reputation: 63

Add column with default null value

I use rails with postgreSQL, I want to add a new column with a default null value, do I have to specify the default null value?

add_column :posts, :string, default: null 

Upvotes: 2

Views: 2825

Answers (1)

P. Boro
P. Boro

Reputation: 776

You don't need to specify it. When you add new column to table without default value all the values will be null. Also: note that in ruby the equivalent of psql Null value is nil.

Upvotes: 5

Related Questions