I followed the setup instructions for a Rails project I've been handed to work on. However, after creating the database and running migrations with bundle exec
, the db/schema.rb
changes. The main change is that the timestamps created_at
and updated_at
lose their null: false
constraint. e.g.:
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at"
+ t.datetime "updated_at"
The project is Rails 4.2 & Ruby 2.4.1.
However, it was originally written with Rails 3.2 and Ruby 1.9.2, so there's the possibility that some of the older code/config is in play(?)
I'm using PostgreSQL: 'pg', '~> 0.17'
.
So: does anyone know why the null: false
has left the schema?
I'd very much like to keep the null: false
constraints, and I guess I can add them back in a migration, but I'm very puzzled why the constraints have disappeared from the schema.
edited to add:
- In the migrations, where t.timestamps
are defined, there isn't a null: false
constraint
- There is no null constraint on the fields in the actual database.
Could earlier versions of ActiveRecord have added the null constraint by default?
I've looked around for answers, but not finding much. This rails issue reports the same thing, but for Oracle.
Here on Stack Overflow, mysql - Rails: differences in db/schema.rb - null: false at created_at/updated_at columns is the same problem, but the suggested solution (drop DB and recreate) didn't help me.