Skip to content

Commit

Permalink
Fix migration generator to support Rails 7.1
Browse files Browse the repository at this point in the history
As in 50285ac we need to support the new location of `timestamped_migrations`
  • Loading branch information
lazyatom authored Feb 9, 2024
1 parent 1ae0270 commit b737eed
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/generators/unread/migration/migration_generator.rb
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
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 b737eed

Please sign in to comment.