I have problem with adding not nullable columns to a table. I read many posts about this and it should be correct.
Migration code:
def change
add_column :individual_trainings, :start_on, :time
add_column :individual_trainings, :end_on, :time
change_column_null :individual_trainings, :start_on, false
change_column_null :individual_trainings, :end_on, false
end
Error:
PG::NotNullViolation: ERROR: column "start_on" contains null values...
I don't have any idea why isn't working. How should I correct write change method?
Thanks in advance.
UPDATE: It was my big fault. I was have one record in this table... I cleared table and migrate. Now it's working. Sorry for my stupidity and waste of your time.