Skip to main content

add_licenses.go

008_add_licenses.go - Overview

  1. Overview

This file defines a SQL migration that creates four tables: licenses, sites, feature_status, and licenses_v3 if they do not already exist. The Up function creates the tables, while the Down function currently does nothing (no rollback).

  1. Detailed Documentation

addLicenses

  • Purpose: Represents the SQL migration for adding license-related tables.

NewAddLicensesFactory

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

newAddLicenses

  • Purpose: Creates a new addLicenses instance.
  • Parameters:
    • _: context.Context - Context, not used in the function.
    • _: factory.ProviderSettings - Factory provider settings, not used in the function.
    • _: Config - Configuration, not used in the function.
  • Returns:
    • SQLMigration: A new addLicenses instance.
    • error: Returns nil.

(*addLicenses) Register

  • Purpose: Registers the Up and Down migration functions.
  • Parameters:
    • migrations: *migrate.Migrations - The migration manager.
  • Returns:
    • error: An error if registration fails, otherwise nil.

(*addLicenses) Up

  • Purpose: Executes the "up" migration, creating the licenses, sites, feature_status, and licenses_v3 tables if they don't exist.
  • Parameters:
    • ctx: context.Context - The context for the operation.
    • db: *bun.DB - The database connection.
  • Returns:
    • error: An error if table creation fails, otherwise nil.

(*addLicenses) Down

  • Purpose: Executes the "down" migration (rollback). Currently, it does nothing.
  • Parameters:
    • ctx: context.Context - The context for the operation.
    • db: *bun.DB - The database connection.
  • Returns:
    • error: Always returns nil.

Include in Getting Started: NO