From 1a363a5862d9ef326f9ec52e2ebf6c33a3932934 Mon Sep 17 00:00:00 2001 From: Gregory Ballantine Date: Thu, 7 Dec 2023 13:04:02 -0500 Subject: [PATCH] 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 --- Rakefile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index 40cc0b1..62a84de 100644 --- a/Rakefile +++ b/Rakefile @@ -1,8 +1,14 @@ require 'bundler/setup' namespace :db do - task :migrate do - %x{sequel -m 'db/migrations/' 'sqlite://data/gamedata.db'} + desc 'Run migrations' + 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