update_pipelines.go
017_update_pipelines.go - Overview
-
Overview This file defines a SQL migration to update the
pipelines
table by addingorg_id
,updated_by
, andupdated_at
columns. It also backfills theorg_id
column if there's only one organization. -
Detailed Documentation
type updatePipelines
- Purpose: Represents the SQL migration for updating the pipelines table.
- Fields:
store
(sqlstore.SQLStore): SQL store instance.
func NewUpdatePipelines
- Purpose: Creates a new
updatePipelines
factory. - Parameters:
sqlstore
(sqlstore.SQLStore): The SQL store to use.
- Returns:
factory.ProviderFactory[SQLMigration, Config]
A factory that can createupdatePipelines
instances.
func newUpdatePipelines
- Purpose: Creates a new
updatePipelines
instance. - Parameters:
_
(context.Context): Context (not used)._
(factory.ProviderSettings): Provider settings (not used)._
(Config): Configuration (not used).store
(sqlstore.SQLStore): SQL store instance.
- Returns:
(SQLMigration, error)
: The newupdatePipelines
instance and an error, if any.
func (*updatePipelines) Register
- Purpose: Registers the Up and Down migration functions.
- Parameters:
migrations
(*migrate.Migrations): The migrations to register with.
- Returns:
error
: An error, if any.
func (*updatePipelines) Up
- Purpose: Implements the "up" migration, adding columns to the
pipelines
table. - Parameters:
ctx
(context.Context): Context for the operation.db
(*bun.DB): The database connection.
- Returns:
error
: An error, if any.- It checks if
org_id
,updated_by
, andupdated_at
columns exist in thepipelines
table. - If a column doesn't exist, it adds the column.
- If there is only one organization, it sets the
org_id
for all pipelines whereorg_id
isNULL
.
- It checks if
func (*updatePipelines) Down
- Purpose: Implements the "down" migration (currently empty).
- Parameters:
ctx
(context.Context): Context for the operation.db
(*bun.DB): The database connection.
- Returns:
error
: Always returnsnil
.
-
Code Examples N/A
-
Clarity and Accuracy The documentation is based on the code and aims to be precise.
-
Markdown & MDX Perfection All markdown is valid.
-
Edge Cases To Avoid Breaking MDX No MDX errors.
-
Getting Started Relevance Include in Getting Started: NO