2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

utcではなく日本時間でmigrationファイルを作りたかった結果

Posted at

ruby on railsでmigrateファイルを作ろうとすると、どうしてもutc時間で生成され、9時間の時差が存在し、違和感を感じます。

time_zoneの設定など、オプションで何かできないかと試行錯誤していましたが、上手く行かず、
migrateしている時に参照している場所を見ていった結果、activerecord-4.2.0/lib/active_record/migration.rbの、next_migration_numberで取得されていました。

   # Determines the version number of the next migration.
    def next_migration_number(number)
      if ActiveRecord::Base.timestamped_migrations
        [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % number].max
      else 
        SchemaMigration.normalize_migration_number(number)
      end  
    end  

常にutc強制だったようです。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?