5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 15:46:21 +00:00
panel/db/migrate/20230927153926_add_last_indexed_commit_to_sites.rb
f 1e13985ef8
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
fix: asumir que todos los sitios ya están indexados
2023-09-27 16:31:23 -03:00

18 lines
507 B
Ruby

# frozen_string_literal: true
# Almacenar el último commit indexado
class AddLastIndexedCommitToSites < ActiveRecord::Migration[6.1]
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