2023-09-27 18:39:12 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# Almacenar el último commit indexado
|
|
|
|
class AddLastIndexedCommitToSites < ActiveRecord::Migration[6.1]
|
2023-09-27 19:31:23 +00:00
|
|
|
def up
|
2023-09-27 18:39:12 +00:00
|
|
|
add_column :sites, :last_indexed_commit, :string, null: true
|
2023-09-27 19:31:23 +00:00
|
|
|
|
|
|
|
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
|
2023-09-27 18:39:12 +00:00
|
|
|
end
|
|
|
|
end
|