← Back to Upcase

Null: false for t.timestamps changed in Rails 4.x?

(Justin Gordon) #1

I ran into an issue where running “annotate -i” removes the not null constraint from timestamps.

I found this SO article: http://stackoverflow.com/questions/20256989/rails-generate-migration-does-not-set-null-false-to-created-at-and-update-at

Seems like maybe the default behavior changed, and if I recreated my development database from migrations, then the schema.rb file wants to change by having “not null” removed.

@greg, any info?

Anybody else?

(Greg Lazarev) #2

I’m not sure what annotate is doing, but you can re-load your schema to get your local db in sync.

(Justin Gordon) #3

Hi @greg, I think annotate is reading the development DB. So what’s happened is that maybe the behavior t.timestamps changed, and I rebuilt the DB from the migrations.

I suppose it might be worth downloading my production DB and running annotate against that and seeing if the “not null” changes in the model annotations.