ubicloud/model/access_tag.rb
Jeremy Evans 2e846e0f7c Add a migration for an index for access_tag.{hyper_tag_id,project_id}
This index should allow use of an index-only scan for the subquery added
by Authorization::HyperTagMethods.filter_authorize_dataset.

This is added in a separate migration, because it uses CREATE
INDEX CONCURRENTLY, and that is not supported inside transactions
(and migrations use transactions by default).  I'm not sure, but
I'm guessing the access_tag table size is large enough we would
want to create the index concurrently to avoid blocking access
to the table.
2024-12-18 09:39:56 -08:00

30 lines
1.1 KiB
Ruby

# frozen_string_literal: true
require_relative "../model"
class AccessTag < Sequel::Model
many_to_one :project
one_to_many :applied_tags
plugin :association_dependencies, applied_tags: :destroy
include ResourceMethods
end
# Table: access_tag
# Columns:
# id | uuid | PRIMARY KEY
# project_id | uuid | NOT NULL
# hyper_tag_id | uuid |
# hyper_tag_table | text | NOT NULL
# name | text | NOT NULL
# created_at | timestamp with time zone | NOT NULL DEFAULT now()
# Indexes:
# access_tag_pkey | PRIMARY KEY btree (id)
# access_tag_project_id_hyper_tag_id_index | UNIQUE btree (project_id, hyper_tag_id)
# access_tag_project_id_name_index | UNIQUE btree (project_id, name)
# access_tag_hyper_tag_id_project_id_index | btree (hyper_tag_id, project_id)
# Foreign key constraints:
# access_tag_project_id_fkey | (project_id) REFERENCES project(id)
# Referenced By:
# applied_tag | applied_tag_access_tag_id_fkey | (access_tag_id) REFERENCES access_tag(id)