modify_org_domain.go
012_modify_org_domain.go - Overview
This file defines a SQL migration to modify the org_domains
table in a SQLite database. Specifically, it renames the updated_at
column, adds a new updated_at
column with INTEGER type, populates it with the old values, and then drops the old column.
Detailed Documentation
modifyOrgDomain
- Purpose: Represents the SQL migration for modifying the
org_domain
table. - Parameters: None
- Returns: None
NewModifyOrgDomainFactory
- Purpose: Creates a new factory for providing the
modifyOrgDomain
SQL migration. - Parameters: None
- Returns:
factory.ProviderFactory[SQLMigration, Config]
: A factory that createsSQLMigration
instances.
newModifyOrgDomain
- Purpose: Creates a new instance of the
modifyOrgDomain
SQL migration. - Parameters:
_ context.Context
: Context._ factory.ProviderSettings
: Factory provider settings._ Config
: Configuration.
- Returns:
(SQLMigration, error)
: A newSQLMigration
instance and an error, if any.
(*modifyOrgDomain) Register
- Purpose: Registers the up and down migration functions with the provided
migrate.Migrations
instance. - Parameters:
migrations *migrate.Migrations
: Themigrate.Migrations
instance to register the migrations with.
- Returns:
error
: An error, if any.
(*modifyOrgDomain) Up
- Purpose: Executes the SQL migration to modify the
org_domains
table. It renames theupdated_at
column toupdated_at_old
, adds a new INTEGERupdated_at
column, copies the data, and drops the old column. This operation is only performed for SQLite databases. - Parameters:
ctx context.Context
: Context for the database operation.db *bun.DB
: The bun database instance.
- Returns:
error
: An error, if any.
(*modifyOrgDomain) Down
- Purpose: Defines the rollback operation for the SQL migration. Currently, it does nothing.
- Parameters:
ctx context.Context
: Context for the database operation.db *bun.DB
: The bun database instance.
- Returns:
error
: An error, if any.
Code Examples
None
Clarity and Accuracy
The documentation is based on the code provided and avoids making assumptions.
Include in Getting Started: NO