From 93d2090011b5ccab504b8aeabf6a95b23193a689 Mon Sep 17 00:00:00 2001 From: Michael Duchemin Date: Sun, 27 Jan 2019 00:23:47 -0500 Subject: 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. --- .../lib/rails/generators/active_record/migration/migration_generator.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activerecord/lib/rails') 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." -- cgit v1.2.3