2

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 
1
  • 1
    posts is table name, string is datatype, then where did you miss column name ? Also you do not need to set default to null for string as its default value is null Commented Feb 4, 2019 at 12:02

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.