From 4d24a9577fed24e5b20093c409ca101b7fd67afd Mon Sep 17 00:00:00 2001 From: Matchu Date: Tue, 18 Jun 2024 14:52:54 -0700 Subject: [PATCH] Only run `public_data:pull` if there are no pending migrations Oh this was a fun little dev environment bug: I ran `public_data:pull` on my laptop before migrating my database, so the `items` table pulled as the latest production version, which included the migrations, but they hadn't been marked as "run" yet. So Rails was still telling me I needed to run them, but the migrations themselves were crashing, with stuff like "there's already a column with this name!" This change ensures that `public_data:pull` won't run until migrations are done, to prevent silly accidents like that. --- lib/tasks/public_data.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/public_data.rake b/lib/tasks/public_data.rake index 7079c58e..789611da 100644 --- a/lib/tasks/public_data.rake +++ b/lib/tasks/public_data.rake @@ -63,7 +63,7 @@ namespace :public_data do end desc "Pull and import the latest public data from production (dev only)" - task :pull => :environment do + task :pull => ["db:abort_if_pending_migrations", :environment] do unless Rails.env.development? raise "Can only pull public data in development mode! This helps us " + "ensure we won't overwrite the production database accidentally."