Class: Rivulet::Steps::RunMigrations
- Inherits:
-
Rivulet::Step
- Object
- Rivulet::Step
- Rivulet::Steps::RunMigrations
- Defined in:
- lib/rivulet/steps/run_migrations.rb
Constant Summary collapse
- TABLE =
:schema_migrations
Instance Method Summary collapse
Methods inherited from Rivulet::Step
container_class_path, inherited
Instance Method Details
#call(input) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rivulet/steps/run_migrations.rb', line 6 def call(input) db = input[:resource].db return Failure("Database not configured") unless db ensure_table(db) migrations = pending(db) if migrations.empty? puts " up to date" else migrations.each do |path| version = File.basename(path, '.sql') db.transaction do db.run(File.read(path)) db[TABLE].insert(version: version) end puts " applied #{File.basename(path)}" end end Success(input) end |