Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the default `null` value for timestamps #16481

Merged
merged 1 commit into from Aug 18, 2014

Conversation

@sgrif
Copy link
Contributor

@sgrif sgrif commented Aug 12, 2014

As per discussion, this changes the model generators to specify
null: false for timestamp columns. A warning is now emitted if
timestamps is called without a null option specified, so we can
safely change the behavior when no option is specified in Rails 5.

As per discussion, this changes the model generators to specify
`null: false` for timestamp columns. A warning is now emitted if
`timestamps` is called without a `null` option specified, so we can
safely change the behavior when no option is specified in Rails 5.
@jeremy
Copy link
Member

@jeremy jeremy commented Aug 12, 2014

Not sure how this can be safe unless old migrations are updated as well? They'll be implicitly null: true, but will generate null: false after the app is upgraded to Rails 5.

@sgrif
Copy link
Contributor Author

@sgrif sgrif commented Aug 12, 2014

That's the goal behind the deprecation warning if it is unspecified, users will need to specify null: true if they would like to keep that behavior, and will receive a deprecation warning until they specify one way or the other.

@jeremy
Copy link
Member

@jeremy jeremy commented Aug 12, 2014

The deprecation warning will come too late though, after the migration already ran on the production db.

@sgrif
Copy link
Contributor Author

@sgrif sgrif commented Aug 12, 2014

The warning would also appear any time anyone did anything related to schema.rb, including running tests after a new migration is created.

dhh added a commit that referenced this pull request Aug 18, 2014
Change the default `null` value for timestamps
@dhh dhh merged commit 7ee0550 into rails:master Aug 18, 2014
1 check passed
1 check passed
continuous-integration/travis-ci The Travis CI build passed
Details
@prathamesh-sonpatki
Copy link
Member

@prathamesh-sonpatki prathamesh-sonpatki commented Sep 28, 2014

@sgrif @jeremy Should this be mentioned in upgrade guide?

@jschroeder9000
Copy link

@jschroeder9000 jschroeder9000 commented Jun 4, 2015

This deprecation only pertains to the timestamps method that creates the created_at and updated_at columns, right? I had a migration that had both t.timestamps and t.timestamp :column_name in it spit this out at me and since the deprecation message says #timestamp (note lack of s) it was a bit confusing.

ggiraldez added a commit to instedd/resourcemap that referenced this pull request Mar 29, 2016
- Use unscoped when referring to Site to remove the deleted_at column in
  SQL queries built by ActiveRecord.
- Add :null => false to all timestamps definitions. Default changed
  from Rails 3.2 to 4.0. See rails/rails#16481
@sgrif sgrif deleted the sgrif:sg-change-default-timestamps branch Mar 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.