migrations

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package migrations provides migration utilities for the subscription plugin.

Index

Constants

This section is empty.

Variables

View Source
var Migrations = migrate.NewMigrations()

Migrations is the collection of all subscription plugin migrations

Functions

func CreateSubscriptionTables

func CreateSubscriptionTables(ctx context.Context, db *bun.DB) error

CreateSubscriptionTables creates all subscription-related tables

func DropSubscriptionTables

func DropSubscriptionTables(ctx context.Context, db *bun.DB) error

DropSubscriptionTables drops all subscription-related tables (for rollback)

Types

type FeaturesMigration

type FeaturesMigration struct {
	// contains filtered or unexported fields
}

FeaturesMigration handles migration of existing PlanFeature data to the new Feature system

func NewFeaturesMigration

func NewFeaturesMigration(db *bun.DB, logger forge.Logger) *FeaturesMigration

NewFeaturesMigration creates a new features migration utility

func (*FeaturesMigration) ExportFeatures

func (m *FeaturesMigration) ExportFeatures(ctx context.Context, appID xid.ID) ([]byte, error)

ExportFeatures exports features and links to JSON format

func (*FeaturesMigration) GetMigrationStatus

func (m *FeaturesMigration) GetMigrationStatus(ctx context.Context, appID xid.ID) (*MigrationStatus, error)

GetMigrationStatus returns the current migration status for an app

func (*FeaturesMigration) MigrateExistingFeatures

func (m *FeaturesMigration) MigrateExistingFeatures(ctx context.Context, appID xid.ID) (*MigrateResult, error)

MigrateExistingFeatures migrates existing PlanFeature entries to the new Feature system This is a non-destructive operation that creates new Feature entities and links them to plans

func (*FeaturesMigration) SyncFeatureFromLegacy

func (m *FeaturesMigration) SyncFeatureFromLegacy(ctx context.Context, appID xid.ID, featureKey string) error

SyncFeatureFromLegacy syncs a single feature from legacy PlanFeature to the new system

func (*FeaturesMigration) ValidateMigration

func (m *FeaturesMigration) ValidateMigration(ctx context.Context, appID xid.ID) (bool, []string, error)

ValidateMigration checks if all existing PlanFeature entries have corresponding Feature entities and links

type MigrateResult

type MigrateResult struct {
	FeaturesCreated int      `json:"featuresCreated"`
	LinksCreated    int      `json:"linksCreated"`
	Errors          []string `json:"errors,omitempty"`
}

MigrateResult contains the results of a migration operation

type MigrationStatus

type MigrationStatus struct {
	OldPlanFeaturesCount int      `json:"oldPlanFeaturesCount"`
	NewFeaturesCount     int      `json:"newFeaturesCount"`
	LinksCount           int      `json:"linksCount"`
	IsValid              bool     `json:"isValid"`
	Issues               []string `json:"issues,omitempty"`
}

MigrationStatus represents the current migration status

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL