Skip to main content

pat_org_domains.go

016_pat_org_domains.go - Overview

  1. Overview This file defines a SQL migration to update the personal_access_tokens and org_domains tables. It adds an org_id column to personal_access_tokens, migrates data to a new org_domains table with a foreign key constraint on org_id, and migrates created_at and updated_at columns to timestamp types. It also drops the ingestion_keys table.

  2. Detailed Documentation

type updatePatAndOrgDomains

  • Purpose: Represents the SQL migration for updating PATs and Org Domains.
  • Parameters: None
  • Returns: None

func NewUpdatePatAndOrgDomainsFactory

  • Purpose: Creates a factory for producing SQLMigration instances related to updating PATs and Org Domains.
  • Parameters:
    • sqlstore (sqlstore.SQLStore): The SQL store instance.
  • Returns: factory.ProviderFactory[SQLMigration, Config]: A factory that produces SQLMigration instances.

func newUpdatePatAndOrgDomains

  • Purpose: Creates a new updatePatAndOrgDomains instance.
  • Parameters:
    • _ (context.Context): Context (not used).
    • _ (factory.ProviderSettings): Provider settings (not used).
    • _ (Config): Configuration (not used).
    • store (sqlstore.SQLStore): The SQL store instance.
  • Returns: (SQLMigration, error): A new updatePatAndOrgDomains instance and an error, if any.

func (*updatePatAndOrgDomains) Register

  • Purpose: Registers the Up and Down migration functions.
  • Parameters:
    • migrations (*migrate.Migrations): The migrations manager.
  • Returns: error: An error, if any.

func (*updatePatAndOrgDomains) Up

  • Purpose: Executes the Up migration, performing schema changes and data migrations.
  • Parameters:
    • ctx (context.Context): The context.
    • db (*bun.DB): The database connection.
  • Returns: error: An error, if any.

func (*updatePatAndOrgDomains) Down

  • Purpose: Executes the Down migration (reverts the Up migration). This implementation is currently empty.
  • Parameters:
    • ctx (context.Context): The context.
    • db (*bun.DB): The database connection.
  • Returns: error: An error, if any.

func updateOrgId

  • Purpose: Updates the org_domains table to include a foreign key reference to the organizations table.
  • Parameters:
    • ctx (context.Context): The context.
    • tx (bun.Tx): The database transaction.
    • table (string): The name of the table to update (expected to be "org_domains").
  • Returns: error: An error, if any.
  1. Code Examples N/A

  2. Clarity and Accuracy The documentation reflects the code accurately.

  3. Markdown & MDX Perfection The markdown syntax is correct.

  4. Edge Cases To Avoid Breaking MDX No issues found.

  5. Getting Started Relevance Include in Getting Started: NO