aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/rails
diff options
context:
space:
mode:
authorMichael Duchemin <msducheminjr@users.noreply.github.com>2019-01-27 00:23:47 -0500
committerMichael Duchemin <msducheminjr@users.noreply.github.com>2019-02-09 15:34:13 -0500
commit93d2090011b5ccab504b8aeabf6a95b23193a689 (patch)
tree8693a081352744a2c770d3c2b072f910975cbfb2 /activerecord/lib/rails
parentea0eaced55465ce8054cf54ff583d75272bd8505 (diff)
downloadrails-93d2090011b5ccab504b8aeabf6a95b23193a689.tar.gz
rails-93d2090011b5ccab504b8aeabf6a95b23193a689.tar.bz2
rails-93d2090011b5ccab504b8aeabf6a95b23193a689.zip
Add class option timestamps to migration generator
Fixes GH#28706. Now rails g migration create_users and rails g model User have the same behavior for timestamps since they implement the same migration template. The expected behavior is that this create table migration will create the table with timestamps unless you pass --no-timestamps or --skip-timestamps to the generator. The expected migration should match what you get when you use the model generator. Using the migration generator, which doesn't have a class_option for timestamps would cause them to not be added to the migration file. Now the migration behavior of the migration generator, create_table only, is aligned with the migration behavior of the model generator. Also modified relevant example of ActiveRecord Migrations Guide.
Diffstat (limited to 'activerecord/lib/rails')
-rw-r--r--activerecord/lib/rails/generators/active_record/migration/migration_generator.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/activerecord/lib/rails/generators/active_record/migration/migration_generator.rb b/activerecord/lib/rails/generators/active_record/migration/migration_generator.rb
index dd79bcf542..b9880895b3 100644
--- a/activerecord/lib/rails/generators/active_record/migration/migration_generator.rb
+++ b/activerecord/lib/rails/generators/active_record/migration/migration_generator.rb
@@ -7,6 +7,7 @@ module ActiveRecord
class MigrationGenerator < Base # :nodoc:
argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]"
+ class_option :timestamps, type: :boolean
class_option :primary_key_type, type: :string, desc: "The type for primary key"
class_option :database, type: :string, aliases: %i(db), desc: "The database for your migration. By default, the current environment's primary database is used."