Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1309,6 +1309,31 @@ class AddFkArticlesToAuthors < ActiveRecord::Migration
end
----

=== Date and Time Columns Naming [[date-and-time-columns-naming]]

Name `date` columns with `_on` suffixes.
Name `datetime` columns with `_at` suffixes.
Name `time` columns (referring to a time of day with no date) with `_time` suffixes.

This enforces consistency and it is easier to tell the type from the name without referring to the database schema.

[source,ruby]
----
# bad
class AddLastActivityToUsers < ActiveRecord::Migration
def change
add_column :users, :last_activity_at, :date
end
end

# good
class AddLastActivityToUsers < ActiveRecord::Migration
def change
add_column :users, :last_activity_on, :date
end
end
----

=== Reversible Migration [[reversible-migration]]

Don't use non-reversible migration commands in the `change` method.
Expand Down