add_organization.go
001_add_organization.go - Overview
-
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
, andingestion_keys
. It uses thebun
library for database interactions and themigrate
package for managing migrations. -
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 createaddOrganization
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
andDown
functions of the migration with the providedmigrate.Migrations
instance. - Parameters:
migrations *migrate.Migrations
: Themigrate.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
andingestion_keys
tables if they don't already exist. - Parameters:
ctx context.Context
: The context for the operation.db *bun.DB
: Thebun.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
: Thebun.DB
instance to use for database operations.
- Returns: Always nil.
- Code Examples N/A
Include in Getting Started: NO