Sha256: 43f18003fe34b6ab4ab35ba443a62072b863eba845ed773b45b8aa561aa86f70
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
require 'rails/generators/active_record' class NotifyUser::AggrIntervalUpdateGenerator < Rails::Generators::Base include Rails::Generators::Migration source_root File.expand_path('../templates', __FILE__) def copy_migrations copy_migration "add_sent_time_to_notifications" copy_migration "update_unsubscribes" puts "Update successful. You can now run:" puts " rake db:migrate" end # This is defined in ActiveRecord::Generators::Base, but that inherits from NamedBase, so it expects a name argument # which we don't want here. So we redefine it here. Yuck. def self.next_migration_number(dirname) if ActiveRecord::Base.timestamped_migrations Time.now.utc.strftime("%Y%m%d%H%M%S") else "%.3d" % (current_migration_number(dirname) + 1) end end protected def copy_migration(filename) if self.class.migration_exists?("db/migrate", "#{filename}") say_status("skipped", "Migration #{filename}.rb already exists") else migration_template "#{filename}.rb", "db/migrate/#{filename}.rb" end end end
Version data entries
2 entries across 2 versions & 1 rubygems