Skip to content

Commit

Permalink
Fix migration generator to support Rails 7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ledermann committed Dec 20, 2023
1 parent b313f2f commit 50285ac
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,22 @@ def create_migration_file
end

def self.next_migration_number(dirname)
if ActiveRecord::Base.timestamped_migrations
Time.now.utc.strftime("%Y%m%d%H%M%S")
if self.timestamped_migrations?
Time.now.utc.strftime('%Y%m%d%H%M%S')
else
"%.3d" % (current_migration_number(dirname) + 1)
end
end

def self.timestamped_migrations?
(
ActiveRecord::Base.respond_to?(:timestamped_migrations) &&
ActiveRecord::Base.timestamped_migrations
) ||
(
ActiveRecord.respond_to?(:timestamped_migrations) &&
ActiveRecord.timestamped_migrations
)
end
end
end

0 comments on commit 50285ac

Please sign in to comment.