main
rb 25 lines 1.07 KB
Raw
1 # frozen_string_literal: true
2
3 # Mirror mode: a repository that keeps an upstream (e.g. GitHub) as the source
4 # of truth and auto-syncs from it. Mirrors are read-only on siGit (pushes are
5 # rejected) to avoid divergence, until the owner "detaches" them into a normal
6 # writable repo.
7 class AddMirrorToRepositories < ActiveRecord::Migration[8.1]
8 def change
9 change_table :repositories, bulk: true do |t|
10 t.boolean :mirror, null: false, default: false
11 t.string :upstream_url # the remote we fetch from
12 # Encrypted upstream credential for private mirrors (ActiveRecord::
13 # Encryption). Nil for public upstreams. Never returned to the client.
14 t.text :upstream_token
15 t.string :mirror_status # ok | syncing | failed
16 t.datetime :mirror_synced_at
17 t.text :mirror_error
18 end
19
20 add_index :repositories, :mirror
21 # Due mirrors are polled by the recurring MirrorSyncScheduler; index the
22 # columns it filters/orders on.
23 add_index :repositories, [ :mirror, :mirror_synced_at ]
24 end
25 end