Improved the db:migrate function in the Rakefile to utilize the Sequel API for running migrations, and to allow downgrading to a specific migration easily

This commit is contained in:
Gregory Ballantine 2023-12-07 13:04:02 -05:00
parent b819f4f1cd
commit 1a363a5862

View File

@ -1,8 +1,14 @@
require 'bundler/setup' require 'bundler/setup'
namespace :db do namespace :db do
task :migrate do desc 'Run migrations'
%x{sequel -m 'db/migrations/' 'sqlite://data/gamedata.db'} task :migrate, [:version] do |t, args|
require "sequel/core"
Sequel.extension :migration
version = args[:version].to_i if args[:version]
Sequel.connect('sqlite://data/gamedata.db') do |db|
Sequel::Migrator.run(db, "db/migrations", target: version)
end
end end
end end