Last active
November 25, 2019 16:55
-
-
Save AlexWayfer/7d10ba0587e5125f00c592f48d66a616 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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