Skip to main content

add_organization.go

001_add_organization.go - Overview

  1. Overview This file defines a SQL migration that creates several tables in a database, including organizations, groups, users, invites, reset_password_request, user_flags, apdex_settings, and ingestion_keys. It uses the bun library for database interactions and the migrate package for managing migrations.

  2. Detailed Documentation

addOrganization

  • Purpose: Represents a database migration to add organization-related tables.

NewAddOrganizationFactory

  • Purpose: Creates a new factory for the addOrganization SQL migration.
  • Returns: A factory.ProviderFactory[SQLMigration, Config] that can create addOrganization instances.

newAddOrganization

  • Purpose: Creates a new addOrganization instance.
  • Parameters:
    • _ context.Context: Context.
    • _ factory.ProviderSettings: Factory settings (not used).
    • _ Config: Configuration (not used).
  • Returns: A new SQLMigration instance (specifically, *addOrganization) and an error (which is always nil in this implementation).

(*addOrganization) Register

  • Purpose: Registers the Up and Down functions of the migration with the provided migrate.Migrations instance.
  • Parameters:
    • migrations *migrate.Migrations: The migrate.Migrations instance to register the migration with.
  • Returns: An error if registration fails, nil otherwise.

(*addOrganization) Up

  • Purpose: Executes the "up" migration, creating the organizations, groups, users, invites, reset_password_request, user_flags, apdex_settings and ingestion_keys tables if they don't already exist.
  • Parameters:
    • ctx context.Context: The context for the operation.
    • db *bun.DB: The bun.DB instance to use for database operations.
  • Returns: An error if any of the table creation operations fail, nil otherwise.

(*addOrganization) Down

  • Purpose: Executes the "down" migration, reverting the changes made by the "up" migration. Currently, it does nothing.
  • Parameters:
    • ctx context.Context: The context for the operation.
    • db *bun.DB: The bun.DB instance to use for database operations.
  • Returns: Always nil.
  1. Code Examples N/A

Include in Getting Started: NO