Sha256: 5cb34fcb3086903c86f5df6543483a7b354c693d88239860d6ff9a7c6c9a9fef
Contents?: true
Size: 963 Bytes
Versions: 2
Compression:
Stored size: 963 Bytes
Contents
# frozen_string_literal: true module Radical class Migration class << self def change(&block) @change = block end def up(&block) @up = block end def down(&block) @down = block end def create_table(name, &block) return drop_table(name) if @change && @rollback table = Table.new(name) block.call(table) "create table #{name} ( id integer primary key, #{table.columns.join(',')} )" end def drop_table(name) "drop table #{name}" end def migrate!(db:, version:) db.execute(@change&.call || @up&.call) db.execute 'insert into radical_migrations (version) values (?)', [version] end def rollback!(db:, version:) @rollback = true db.execute(@change&.call || @down&.call) db.execute 'delete from radical_migrations where version = ?', [version] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
radical-1.2.0 | lib/radical/migration.rb |
radical-1.1.0 | lib/radical/migration.rb |