Skip to content

Instantly share code, notes, and snippets.

@AlexWayfer
Last active November 25, 2019 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexWayfer/7d10ba0587e5125f00c592f48d66a616 to your computer and use it in GitHub Desktop.
Save AlexWayfer/7d10ba0587e5125f00c592f48d66a616 to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
def db_migrations
return @db_migrations if defined?(@db_migrations)
puts "Request to DB from #{self.class} (#{object_id})"
@db_migrations = [3, 5]
end
# frozen_string_literal: true
require_relative '.preload'
## Class for migration (file)
class Migration
def initialize(version)
@version = version
end
def applied?
db_migrations.include?(@version)
end
def print
puts "Migration #{@version} #{applied? ? 'is' : 'is not'} applied"
end
end
migrations = (1..6).map { |version| Migration.new(version) }
migrations.each(&:print)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment