From 1e13985ef82c0dde7068db2bd0e027e8f8419434 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 27 Sep 2023 16:31:23 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20asumir=20que=20todos=20los=20sitios=20ya?= =?UTF-8?q?=20est=C3=A1n=20indexados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0230927153926_add_last_indexed_commit_to_sites.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/db/migrate/20230927153926_add_last_indexed_commit_to_sites.rb b/db/migrate/20230927153926_add_last_indexed_commit_to_sites.rb index 2d22cbd7..71e08f37 100644 --- a/db/migrate/20230927153926_add_last_indexed_commit_to_sites.rb +++ b/db/migrate/20230927153926_add_last_indexed_commit_to_sites.rb @@ -2,7 +2,17 @@ # Almacenar el último commit indexado class AddLastIndexedCommitToSites < ActiveRecord::Migration[6.1] - def change + def up add_column :sites, :last_indexed_commit, :string, null: true + + Site.find_each do |site| + site.update_columns(last_indexed_commit: site.repository.head_commit.oid) + rescue Rugged::Error, Rugged::OSError => e + puts "Falló #{site.name}, ignorando: #{e.message}" + end + end + + def down + remove_column :sites, :last_indexed_commit end end