Sha256: badcf849ff1d8997cecc2749b36c91844d3733608d845611c749cbc6c6b368f4
Contents?: true
Size: 1.16 KB
Versions: 2
Compression:
Stored size: 1.16 KB
Contents
module Artaius # Internal: Connect Artaius to the database via Sequel interface. Database = Sequel.sqlite(File.join(File.expand_path('db'), 'artaius.db')) class << Database # Internal: Migrate database from older version to the new one or vice # versa. Without given arguments, migrate database to the latest version # available. # # to - The Integer, describes version, to version till which migrations # should be applied (default: nil). # from - The Integer, describes version, from which migration should start # its work (default: nil). # # Returns nothing. def migrate(to = nil, from = nil) migrations = File.join(File.expand_path('db'), 'migrations') if to == 0 && from == 0 Sequel::Migrator.apply(self, migrations) else Sequel::Migrator.apply(self, migrations, to, from) end end # Internal: Rollback current version of database to the previous one. This # method returns database exactly one step back. # # Returns nothing def rollback current_version = self[:schema_info].first[:version] migrate(current_version.pred) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
artaius-0.2.1 | lib/artaius/database.rb |
artaius-0.2.0 | lib/artaius/database.rb |