Files
ubicloud/migrate/20240417_github_repository.rb
Enes Cakir ac062cb8c0 Add migration for GithubRepository model
GitHub provides an API endpoint to access installation repositories.
However, not all customers use Ubicloud runners for all their
repositories. While we have information of active repositories in the
DeletedRecord, we prefer not to use it for application logic. Therefore,
I've introduced the GithubRunner model to maintain a list of active
repositories. This model is created when the first job is delivered for
the repository. It also includes a 'last_job_at' column to help to clean
up inactive repositories. Our job polling mechanism need active
repositories.
2024-04-17 18:49:52 +03:00

20 lines
737 B
Ruby

# frozen_string_literal: true
Sequel.migration do
change do
create_table(:github_repository) do
column :id, :uuid, primary_key: true, default: nil
foreign_key :installation_id, :github_installation, type: :uuid
column :name, :text, collate: '"C"', null: false
column :created_at, :timestamptz, null: false, default: Sequel::CURRENT_TIMESTAMP
column :last_job_at, :timestamptz, null: false, default: Sequel::CURRENT_TIMESTAMP
column :last_check_at, :timestamptz, null: false, default: Sequel::CURRENT_TIMESTAMP
index [:installation_id, :name], unique: true
end
alter_table(:github_runner) do
add_foreign_key :repository_id, :github_repository, type: :uuid
end
end
end