migrations

package
v0.0.0-...-8a0222f Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: AGPL-3.0, GPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRegistry = &MigrationRegistryImpl{
	migrations: make(map[float64]MajorMigrationInterface),
}

DefaultRegistry is the global migration registry

View Source
var ErrRestartRequired = errors.New("migration completed successfully - server restart required")

ErrRestartRequired is returned when a migration requires a server restart

Functions

func CompareVersions

func CompareVersions(v1, v2 string) (int, error)

CompareVersions compares two version strings Returns: -1 if v1 < v2, 0 if v1 == v2, 1 if v1 > v2

func GetCurrentCodeVersion

func GetCurrentCodeVersion() (float64, error)

GetCurrentCodeVersion returns the major version from config.VERSION

func IsVersionSuperior

func IsVersionSuperior(currentVersion, newVersion string) (bool, error)

IsVersionSuperior checks if newVersion is superior to currentVersion

func ParseVersion

func ParseVersion(versionStr string) (float64, error)

ParseVersion parses version string like "v3.14" or "3.14" and returns major version

func Register

func Register(migration MajorMigrationInterface)

Register is a convenience function to register migrations with the default registry

Types

type DBExecutor

type DBExecutor interface {
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
}

DBExecutor represents a database connection that can execute queries

type MajorMigrationInterface

type MajorMigrationInterface interface {
	GetMajorVersion() float64
	HasSystemUpdate() bool
	HasWorkspaceUpdate() bool
	ShouldRestartServer() bool
	UpdateSystem(ctx context.Context, config *config.Config, db DBExecutor) error
	UpdateWorkspace(ctx context.Context, config *config.Config, workspace *domain.Workspace, db DBExecutor) error
}

MajorMigrationInterface defines a major version migration

func GetRegisteredMigration

func GetRegisteredMigration(version float64) (MajorMigrationInterface, bool)

GetRegisteredMigration returns a specific migration from the default registry

func GetRegisteredMigrations

func GetRegisteredMigrations() []MajorMigrationInterface

GetRegisteredMigrations returns all registered migrations from the default registry

type Manager

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

Manager implements MigrationManager

func NewManager

func NewManager(logger logger.Logger) *Manager

NewManager creates a new migration manager

func (*Manager) GetCurrentDBVersion

func (m *Manager) GetCurrentDBVersion(ctx context.Context, db *sql.DB) (float64, error, bool)

GetCurrentDBVersion retrieves the current database version from settings table

func (*Manager) RunMigrations

func (m *Manager) RunMigrations(ctx context.Context, cfg *config.Config, db *sql.DB) error

RunMigrations executes all necessary migrations based on version comparison

func (*Manager) SetCurrentDBVersion

func (m *Manager) SetCurrentDBVersion(ctx context.Context, db *sql.DB, version float64) error

SetCurrentDBVersion updates the current database version in settings table

type MigrationManager

type MigrationManager interface {
	GetCurrentDBVersion(ctx context.Context, db *sql.DB) (float64, error, bool)
	SetCurrentDBVersion(ctx context.Context, db *sql.DB, version float64) error
	RunMigrations(ctx context.Context, config *config.Config, db *sql.DB) error
}

MigrationManager interface for managing migrations

type MigrationRegistry

type MigrationRegistry interface {
	Register(migration MajorMigrationInterface)
	GetMigrations() []MajorMigrationInterface
	GetMigration(version float64) (MajorMigrationInterface, bool)
}

MigrationRegistry manages registered migrations

type MigrationRegistryImpl

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

MigrationRegistryImpl implements MigrationRegistry

func (*MigrationRegistryImpl) GetMigration

func (r *MigrationRegistryImpl) GetMigration(version float64) (MajorMigrationInterface, bool)

GetMigration returns a specific migration by version

func (*MigrationRegistryImpl) GetMigrations

func (r *MigrationRegistryImpl) GetMigrations() []MajorMigrationInterface

GetMigrations returns all registered migrations sorted by version

func (*MigrationRegistryImpl) Register

func (r *MigrationRegistryImpl) Register(migration MajorMigrationInterface)

Register adds a migration to the registry

type V4Migration

type V4Migration struct{}

V4Migration implements the migration from version 3.x to 4.0

func (*V4Migration) GetMajorVersion

func (m *V4Migration) GetMajorVersion() float64

GetMajorVersion returns the major version this migration handles

func (*V4Migration) HasSystemUpdate

func (m *V4Migration) HasSystemUpdate() bool

HasSystemUpdate indicates if this migration has system-level changes

func (*V4Migration) HasWorkspaceUpdate

func (m *V4Migration) HasWorkspaceUpdate() bool

HasWorkspaceUpdate indicates if this migration has workspace-level changes

func (*V4Migration) ShouldRestartServer

func (m *V4Migration) ShouldRestartServer() bool

ShouldRestartServer indicates if the server should restart after this migration

func (*V4Migration) UpdateSystem

func (m *V4Migration) UpdateSystem(ctx context.Context, config *config.Config, db DBExecutor) error

UpdateSystem executes system-level migration changes

func (*V4Migration) UpdateWorkspace

func (m *V4Migration) UpdateWorkspace(ctx context.Context, config *config.Config, workspace *domain.Workspace, db DBExecutor) error

UpdateWorkspace executes workspace-level migration changes

type V5Migration

type V5Migration struct{}

V5Migration implements the migration from version 4.x to 5.0

func (*V5Migration) GetMajorVersion

func (m *V5Migration) GetMajorVersion() float64

GetMajorVersion returns the major version this migration handles

func (*V5Migration) HasSystemUpdate

func (m *V5Migration) HasSystemUpdate() bool

HasSystemUpdate indicates if this migration has system-level changes

func (*V5Migration) HasWorkspaceUpdate

func (m *V5Migration) HasWorkspaceUpdate() bool

HasWorkspaceUpdate indicates if this migration has workspace-level changes

func (*V5Migration) ShouldRestartServer

func (m *V5Migration) ShouldRestartServer() bool

ShouldRestartServer indicates if the server should restart after this migration

func (*V5Migration) UpdateSystem

func (m *V5Migration) UpdateSystem(ctx context.Context, config *config.Config, db DBExecutor) error

UpdateSystem executes system-level migration changes

func (*V5Migration) UpdateWorkspace

func (m *V5Migration) UpdateWorkspace(ctx context.Context, config *config.Config, workspace *domain.Workspace, db DBExecutor) error

UpdateWorkspace executes workspace-level migration changes

type V6Migration

type V6Migration struct{}

V6Migration implements the migration from version 5.x to 6.0

func (*V6Migration) GetMajorVersion

func (m *V6Migration) GetMajorVersion() float64

GetMajorVersion returns the major version this migration handles

func (*V6Migration) HasSystemUpdate

func (m *V6Migration) HasSystemUpdate() bool

HasSystemUpdate indicates if this migration has system-level changes

func (*V6Migration) HasWorkspaceUpdate

func (m *V6Migration) HasWorkspaceUpdate() bool

HasWorkspaceUpdate indicates if this migration has workspace-level changes

func (*V6Migration) ShouldRestartServer

func (m *V6Migration) ShouldRestartServer() bool

ShouldRestartServer indicates if the server should restart after this migration

func (*V6Migration) UpdateSystem

func (m *V6Migration) UpdateSystem(ctx context.Context, config *config.Config, db DBExecutor) error

UpdateSystem executes system-level migration changes

func (*V6Migration) UpdateWorkspace

func (m *V6Migration) UpdateWorkspace(ctx context.Context, config *config.Config, workspace *domain.Workspace, db DBExecutor) error

UpdateWorkspace executes workspace-level migration changes

type V7Migration

type V7Migration struct{}

V7Migration implements the migration from version 6.x to 7.0 Adds contact_timeline table and triggers for tracking contact and contact_list changes

func (*V7Migration) GetMajorVersion

func (m *V7Migration) GetMajorVersion() float64

GetMajorVersion returns the major version this migration handles

func (*V7Migration) HasSystemUpdate

func (m *V7Migration) HasSystemUpdate() bool

HasSystemUpdate indicates if this migration has system-level changes

func (*V7Migration) HasWorkspaceUpdate

func (m *V7Migration) HasWorkspaceUpdate() bool

HasWorkspaceUpdate indicates if this migration has workspace-level changes

func (*V7Migration) ShouldRestartServer

func (m *V7Migration) ShouldRestartServer() bool

ShouldRestartServer indicates if the server should restart after this migration

func (*V7Migration) UpdateSystem

func (m *V7Migration) UpdateSystem(ctx context.Context, config *config.Config, db DBExecutor) error

UpdateSystem executes system-level migration changes

func (*V7Migration) UpdateWorkspace

func (m *V7Migration) UpdateWorkspace(ctx context.Context, config *config.Config, workspace *domain.Workspace, db DBExecutor) error

UpdateWorkspace executes workspace-level migration changes

type V8Migration

type V8Migration struct{}

V8Migration implements the migration from version 7.x to 8.0 Adds kind and db_created_at columns to contact_timeline table Removes default from created_at to support historical data imports

func (*V8Migration) GetMajorVersion

func (m *V8Migration) GetMajorVersion() float64

GetMajorVersion returns the major version this migration handles

func (*V8Migration) HasSystemUpdate

func (m *V8Migration) HasSystemUpdate() bool

HasSystemUpdate indicates if this migration has system-level changes

func (*V8Migration) HasWorkspaceUpdate

func (m *V8Migration) HasWorkspaceUpdate() bool

HasWorkspaceUpdate indicates if this migration has workspace-level changes

func (*V8Migration) ShouldRestartServer

func (m *V8Migration) ShouldRestartServer() bool

ShouldRestartServer indicates if the server should restart after this migration

func (*V8Migration) UpdateSystem

func (m *V8Migration) UpdateSystem(ctx context.Context, config *config.Config, db DBExecutor) error

UpdateSystem executes system-level migration changes

func (*V8Migration) UpdateWorkspace

func (m *V8Migration) UpdateWorkspace(ctx context.Context, config *config.Config, workspace *domain.Workspace, db DBExecutor) error

UpdateWorkspace executes workspace-level migration changes

type V9Migration

type V9Migration struct{}

V9Migration implements the migration from version 8.x to 9.0 Adds message_attachments table and attachments column to message_history

func (*V9Migration) GetMajorVersion

func (m *V9Migration) GetMajorVersion() float64

GetMajorVersion returns the major version this migration handles

func (*V9Migration) HasSystemUpdate

func (m *V9Migration) HasSystemUpdate() bool

HasSystemUpdate indicates if this migration has system-level changes

func (*V9Migration) HasWorkspaceUpdate

func (m *V9Migration) HasWorkspaceUpdate() bool

HasWorkspaceUpdate indicates if this migration has workspace-level changes

func (*V9Migration) ShouldRestartServer

func (m *V9Migration) ShouldRestartServer() bool

ShouldRestartServer indicates if the server should restart after this migration

func (*V9Migration) UpdateSystem

func (m *V9Migration) UpdateSystem(ctx context.Context, config *config.Config, db DBExecutor) error

UpdateSystem executes system-level migration changes (none for v9)

func (*V9Migration) UpdateWorkspace

func (m *V9Migration) UpdateWorkspace(ctx context.Context, config *config.Config, workspace *domain.Workspace, db DBExecutor) error

UpdateWorkspace executes workspace-level migration changes

type V10Migration

type V10Migration struct{}

V10Migration implements the migration from version 9.x to 10.0 Adds list_ids column to message_history and creates trigger to auto-update contact_lists on complaint/bounce

func (*V10Migration) GetMajorVersion

func (m *V10Migration) GetMajorVersion() float64

GetMajorVersion returns the major version this migration handles

func (*V10Migration) HasSystemUpdate

func (m *V10Migration) HasSystemUpdate() bool

HasSystemUpdate indicates if this migration has system-level changes

func (*V10Migration) HasWorkspaceUpdate

func (m *V10Migration) HasWorkspaceUpdate() bool

HasWorkspaceUpdate indicates if this migration has workspace-level changes

func (*V10Migration) ShouldRestartServer

func (m *V10Migration) ShouldRestartServer() bool

ShouldRestartServer indicates if the server should restart after this migration

func (*V10Migration) UpdateSystem

func (m *V10Migration) UpdateSystem(ctx context.Context, config *config.Config, db DBExecutor) error

UpdateSystem executes system-level migration changes (none for v10)

func (*V10Migration) UpdateWorkspace

func (m *V10Migration) UpdateWorkspace(ctx context.Context, config *config.Config, workspace *domain.Workspace, db DBExecutor) error

UpdateWorkspace executes workspace-level migration changes

type V11Migration

type V11Migration struct{}

V11Migration implements the migration from version 10.x to 11.0 Marks existing deployments as installed without migrating env vars (env vars always win)

func (*V11Migration) GetMajorVersion

func (m *V11Migration) GetMajorVersion() float64

GetMajorVersion returns the major version this migration handles

func (*V11Migration) HasSystemUpdate

func (m *V11Migration) HasSystemUpdate() bool

HasSystemUpdate indicates if this migration has system-level changes

func (*V11Migration) HasWorkspaceUpdate

func (m *V11Migration) HasWorkspaceUpdate() bool

HasWorkspaceUpdate indicates if this migration has workspace-level changes

func (*V11Migration) ShouldRestartServer

func (m *V11Migration) ShouldRestartServer() bool

ShouldRestartServer indicates if the server should restart after this migration

func (*V11Migration) UpdateSystem

func (m *V11Migration) UpdateSystem(ctx context.Context, cfg *config.Config, db DBExecutor) error

UpdateSystem executes system-level migration changes Marks existing installations as installed without migrating env vars to database With v11+, env vars always take precedence and should NOT be stored in database

func (*V11Migration) UpdateWorkspace

func (m *V11Migration) UpdateWorkspace(ctx context.Context, cfg *config.Config, workspace *domain.Workspace, db DBExecutor) error

UpdateWorkspace executes workspace-level migration changes (none for v11)

type V12Migration

type V12Migration struct{}

V12Migration implements the migration from version 11.x to 12.0 Sets default rate limit on all email provider integrations

func (*V12Migration) GetMajorVersion

func (m *V12Migration) GetMajorVersion() float64

GetMajorVersion returns the major version this migration handles

func (*V12Migration) HasSystemUpdate

func (m *V12Migration) HasSystemUpdate() bool

HasSystemUpdate indicates if this migration has system-level changes

func (*V12Migration) HasWorkspaceUpdate

func (m *V12Migration) HasWorkspaceUpdate() bool

HasWorkspaceUpdate indicates if this migration has workspace-level changes

func (*V12Migration) ShouldRestartServer

func (m *V12Migration) ShouldRestartServer() bool

ShouldRestartServer indicates if the server should restart after this migration

func (*V12Migration) UpdateSystem

func (m *V12Migration) UpdateSystem(ctx context.Context, cfg *config.Config, db DBExecutor) error

UpdateSystem executes system-level migration changes Adds default rate_limit_per_minute to all email provider integrations

func (*V12Migration) UpdateWorkspace

func (m *V12Migration) UpdateWorkspace(ctx context.Context, cfg *config.Config, workspace *domain.Workspace, db DBExecutor) error

UpdateWorkspace executes workspace-level migration changes (none for v12)

type V13Migration

type V13Migration struct{}

V13Migration implements the migration from version 12.x to 13.0 Adds recompute_after column to segments table for daily segment recomputation Creates permanent task for each workspace to check for segments due for recomputation

func (*V13Migration) GetMajorVersion

func (m *V13Migration) GetMajorVersion() float64

GetMajorVersion returns the major version this migration handles

func (*V13Migration) HasSystemUpdate

func (m *V13Migration) HasSystemUpdate() bool

HasSystemUpdate indicates if this migration has system-level changes

func (*V13Migration) HasWorkspaceUpdate

func (m *V13Migration) HasWorkspaceUpdate() bool

HasWorkspaceUpdate indicates if this migration has workspace-level changes

func (*V13Migration) ShouldRestartServer

func (m *V13Migration) ShouldRestartServer() bool

ShouldRestartServer indicates if the server should restart after this migration

func (*V13Migration) UpdateSystem

func (m *V13Migration) UpdateSystem(ctx context.Context, config *config.Config, db DBExecutor) error

UpdateSystem executes system-level migration changes

func (*V13Migration) UpdateWorkspace

func (m *V13Migration) UpdateWorkspace(ctx context.Context, config *config.Config, workspace *domain.Workspace, db DBExecutor) error

UpdateWorkspace executes workspace-level migration changes

type V14Migration

type V14Migration struct{}

V14Migration adds channel_options JSONB column to message_history table and sets telemetry/check_for_updates defaults for existing installations

func (*V14Migration) GetMajorVersion

func (m *V14Migration) GetMajorVersion() float64

func (*V14Migration) HasSystemUpdate

func (m *V14Migration) HasSystemUpdate() bool

func (*V14Migration) HasWorkspaceUpdate

func (m *V14Migration) HasWorkspaceUpdate() bool

func (*V14Migration) ShouldRestartServer

func (m *V14Migration) ShouldRestartServer() bool

func (*V14Migration) UpdateSystem

func (m *V14Migration) UpdateSystem(ctx context.Context, config *config.Config, db DBExecutor) error

func (*V14Migration) UpdateWorkspace

func (m *V14Migration) UpdateWorkspace(ctx context.Context, config *config.Config, workspace *domain.Workspace, db DBExecutor) error

type V15Migration

type V15Migration struct{}

V15Migration migrates from PASETO to JWT authentication - Removes PASETO key settings from database - Invalidates all API keys (PASETO tokens incompatible with JWT)

func (*V15Migration) GetMajorVersion

func (m *V15Migration) GetMajorVersion() float64

func (*V15Migration) HasSystemUpdate

func (m *V15Migration) HasSystemUpdate() bool

func (*V15Migration) HasWorkspaceUpdate

func (m *V15Migration) HasWorkspaceUpdate() bool

func (*V15Migration) ShouldRestartServer

func (m *V15Migration) ShouldRestartServer() bool

func (*V15Migration) UpdateSystem

func (m *V15Migration) UpdateSystem(ctx context.Context, cfg *config.Config, db DBExecutor) error

func (*V15Migration) UpdateWorkspace

func (m *V15Migration) UpdateWorkspace(ctx context.Context, cfg *config.Config, workspace *domain.Workspace, db DBExecutor) error

type V16Migration

type V16Migration struct{}

V16Migration adds integration_id column to templates table This allows templates to be marked as managed by integrations (e.g., Supabase) Integration-managed templates cannot be deleted by users

func (*V16Migration) GetMajorVersion

func (m *V16Migration) GetMajorVersion() float64

func (*V16Migration) HasSystemUpdate

func (m *V16Migration) HasSystemUpdate() bool

func (*V16Migration) HasWorkspaceUpdate

func (m *V16Migration) HasWorkspaceUpdate() bool

func (*V16Migration) ShouldRestartServer

func (m *V16Migration) ShouldRestartServer() bool

func (*V16Migration) UpdateSystem

func (m *V16Migration) UpdateSystem(ctx context.Context, config *config.Config, db DBExecutor) error

func (*V16Migration) UpdateWorkspace

func (m *V16Migration) UpdateWorkspace(ctx context.Context, config *config.Config, workspace *domain.Workspace, db DBExecutor) error

type V17Migration

type V17Migration struct{}

V17Migration updates mailing list structure and adds blog feature System: Add blog permissions to all user workspaces Broadcasts: pause_reason, audience.lists -> audience.list Message history: list_ids -> list_id Workspace: Create blog_categories and blog_posts tables

func (*V17Migration) GetMajorVersion

func (m *V17Migration) GetMajorVersion() float64

func (*V17Migration) HasSystemUpdate

func (m *V17Migration) HasSystemUpdate() bool

func (*V17Migration) HasWorkspaceUpdate

func (m *V17Migration) HasWorkspaceUpdate() bool

func (*V17Migration) ShouldRestartServer

func (m *V17Migration) ShouldRestartServer() bool

func (*V17Migration) UpdateSystem

func (m *V17Migration) UpdateSystem(ctx context.Context, config *config.Config, db DBExecutor) error

func (*V17Migration) UpdateWorkspace

func (m *V17Migration) UpdateWorkspace(ctx context.Context, config *config.Config, workspace *domain.Workspace, db DBExecutor) error

type V18Migration

type V18Migration struct{}

V18Migration adds custom events system and semantic naming for all internal timeline events This migration includes: 1. Custom events table and timeline trigger (generic, no hardcoded logic) 2. Contact list semantic naming (list.subscribed, list.unsubscribed, etc.) 3. Segment semantic naming (segment.joined, segment.left) 4. Contact semantic naming (contact.created, contact.updated) 5. Historical data migration for all three entity types 6. Remove deprecated contact fields (lifetime_value, orders_count, last_order_at) - now handled by custom_events_goals

func (*V18Migration) GetMajorVersion

func (m *V18Migration) GetMajorVersion() float64

func (*V18Migration) HasSystemUpdate

func (m *V18Migration) HasSystemUpdate() bool

func (*V18Migration) HasWorkspaceUpdate

func (m *V18Migration) HasWorkspaceUpdate() bool

func (*V18Migration) ShouldRestartServer

func (m *V18Migration) ShouldRestartServer() bool

func (*V18Migration) UpdateSystem

func (m *V18Migration) UpdateSystem(ctx context.Context, config *config.Config, db DBExecutor) error

func (*V18Migration) UpdateWorkspace

func (m *V18Migration) UpdateWorkspace(ctx context.Context, config *config.Config, workspace *domain.Workspace, db DBExecutor) error

type V19Migration

type V19Migration struct{}

V19Migration adds webhook subscription system for outgoing webhooks This migration includes: 1. webhook_subscriptions table for storing webhook endpoint configurations 2. webhook_deliveries table for queuing and tracking webhook deliveries 3. 5 trigger functions for capturing events from: contacts, contact_lists, contact_segments, message_history, custom_events 4. full_name contact field + fix timeline timestamps to use CURRENT_TIMESTAMP

func (*V19Migration) GetMajorVersion

func (m *V19Migration) GetMajorVersion() float64

func (*V19Migration) HasSystemUpdate

func (m *V19Migration) HasSystemUpdate() bool

func (*V19Migration) HasWorkspaceUpdate

func (m *V19Migration) HasWorkspaceUpdate() bool

func (*V19Migration) ShouldRestartServer

func (m *V19Migration) ShouldRestartServer() bool

func (*V19Migration) UpdateSystem

func (m *V19Migration) UpdateSystem(ctx context.Context, config *config.Config, db DBExecutor) error

func (*V19Migration) UpdateWorkspace

func (m *V19Migration) UpdateWorkspace(ctx context.Context, config *config.Config, workspace *domain.Workspace, db DBExecutor) error

type V20Migration

type V20Migration struct{}

V20Migration adds automation system tables

func (*V20Migration) GetMajorVersion

func (m *V20Migration) GetMajorVersion() float64

func (*V20Migration) HasSystemUpdate

func (m *V20Migration) HasSystemUpdate() bool

func (*V20Migration) HasWorkspaceUpdate

func (m *V20Migration) HasWorkspaceUpdate() bool

func (*V20Migration) ShouldRestartServer

func (m *V20Migration) ShouldRestartServer() bool

func (*V20Migration) UpdateSystem

func (m *V20Migration) UpdateSystem(ctx context.Context, config *config.Config, db DBExecutor) error

func (*V20Migration) UpdateWorkspace

func (m *V20Migration) UpdateWorkspace(ctx context.Context, config *config.Config, workspace *domain.Workspace, db DBExecutor) error

type V21Migration

type V21Migration struct{}

V21Migration adds email queue tables for unified broadcast and automation email sending

func (*V21Migration) GetMajorVersion

func (m *V21Migration) GetMajorVersion() float64

func (*V21Migration) HasSystemUpdate

func (m *V21Migration) HasSystemUpdate() bool

func (*V21Migration) HasWorkspaceUpdate

func (m *V21Migration) HasWorkspaceUpdate() bool

func (*V21Migration) ShouldRestartServer

func (m *V21Migration) ShouldRestartServer() bool

func (*V21Migration) UpdateSystem

func (m *V21Migration) UpdateSystem(ctx context.Context, cfg *config.Config, db DBExecutor) error

func (*V21Migration) UpdateWorkspace

func (m *V21Migration) UpdateWorkspace(ctx context.Context, cfg *config.Config, workspace *domain.Workspace, db DBExecutor) error

type V22Migration

type V22Migration struct{}

V22Migration adds LLM permissions to existing users

func (*V22Migration) GetMajorVersion

func (m *V22Migration) GetMajorVersion() float64

func (*V22Migration) HasSystemUpdate

func (m *V22Migration) HasSystemUpdate() bool

func (*V22Migration) HasWorkspaceUpdate

func (m *V22Migration) HasWorkspaceUpdate() bool

func (*V22Migration) ShouldRestartServer

func (m *V22Migration) ShouldRestartServer() bool

func (*V22Migration) UpdateSystem

func (m *V22Migration) UpdateSystem(ctx context.Context, cfg *config.Config, db DBExecutor) error

func (*V22Migration) UpdateWorkspace

func (m *V22Migration) UpdateWorkspace(ctx context.Context, cfg *config.Config, workspace *domain.Workspace, db DBExecutor) error

type V23Migration

type V23Migration struct{}

V23Migration reinstalls trigger functions with correct semantic event kinds This migration fixes workspaces that were created with outdated trigger functions from init.go that produced generic kinds (insert_contact_list) instead of semantic kinds (list.subscribed, list.confirmed, etc.)

Background: V18 introduced semantic event naming for timeline events, but init.go was never updated. New workspaces created after V18 got the old trigger functions from init.go, causing automation triggers to never fire (they look for 'list.subscribed' but the trigger produces 'insert_contact_list').

func (*V23Migration) GetMajorVersion

func (m *V23Migration) GetMajorVersion() float64

func (*V23Migration) HasSystemUpdate

func (m *V23Migration) HasSystemUpdate() bool

func (*V23Migration) HasWorkspaceUpdate

func (m *V23Migration) HasWorkspaceUpdate() bool

func (*V23Migration) ShouldRestartServer

func (m *V23Migration) ShouldRestartServer() bool

func (*V23Migration) UpdateSystem

func (m *V23Migration) UpdateSystem(ctx context.Context, cfg *config.Config, db DBExecutor) error

func (*V23Migration) UpdateWorkspace

func (m *V23Migration) UpdateWorkspace(ctx context.Context, cfg *config.Config, workspace *domain.Workspace, db DBExecutor) error

type V24Migration

type V24Migration struct{}

V24Migration fixes automation stats field that may contain JSONB scalar values instead of proper JSONB objects.

Root cause: When creating automations, if Stats was nil (not provided by frontend), json.Marshal(nil) produced "null" which was stored as JSONB null - a scalar value. Later, when automation_enroll_contact tries to use jsonb_set on the stats field, PostgreSQL throws "cannot set path in scalar" because jsonb_set cannot operate on scalar values (null, numbers, strings, booleans).

This migration: 1. Fixes any existing automations with scalar stats to use empty object '{}' 2. The code fix in automation_postgres.go prevents new automations from having this issue

func (*V24Migration) GetMajorVersion

func (m *V24Migration) GetMajorVersion() float64

func (*V24Migration) HasSystemUpdate

func (m *V24Migration) HasSystemUpdate() bool

func (*V24Migration) HasWorkspaceUpdate

func (m *V24Migration) HasWorkspaceUpdate() bool

func (*V24Migration) ShouldRestartServer

func (m *V24Migration) ShouldRestartServer() bool

func (*V24Migration) UpdateSystem

func (m *V24Migration) UpdateSystem(ctx context.Context, cfg *config.Config, db DBExecutor) error

func (*V24Migration) UpdateWorkspace

func (m *V24Migration) UpdateWorkspace(ctx context.Context, cfg *config.Config, workspace *domain.Workspace, db DBExecutor) error

type V25Migration

type V25Migration struct{}

V25Migration fixes automation_enroll_contact to not check list subscription.

Bug (GitHub Issue #191): The function incorrectly checked if contact is subscribed to automation.list_id before enrolling. But list_id is only for unsubscribe URLs in email templates, not enrollment filtering.

Impact: Any automation with a list_id set (required for email nodes) would fail to enroll contacts for non-list triggers like contact.created, because a newly created contact can never be subscribed to a list yet.

Fix: 1. Remove the p_list_id parameter from automation_enroll_contact() entirely 2. Regenerate all existing automation trigger functions to use 4 params instead of 5

func (*V25Migration) GetMajorVersion

func (m *V25Migration) GetMajorVersion() float64

func (*V25Migration) HasSystemUpdate

func (m *V25Migration) HasSystemUpdate() bool

func (*V25Migration) HasWorkspaceUpdate

func (m *V25Migration) HasWorkspaceUpdate() bool

func (*V25Migration) ShouldRestartServer

func (m *V25Migration) ShouldRestartServer() bool

func (*V25Migration) UpdateSystem

func (m *V25Migration) UpdateSystem(ctx context.Context, cfg *config.Config, db DBExecutor) error

func (*V25Migration) UpdateWorkspace

func (m *V25Migration) UpdateWorkspace(ctx context.Context, cfg *config.Config, workspace *domain.Workspace, db DBExecutor) error

type V26Migration

type V26Migration struct{}

V26Migration fixes invalid 'subscribed' status values and recomputes automation stats.

Bugs fixed: 1. Automation add_to_list nodes used 'subscribed' instead of 'active' status 2. Automation stats could be reset to 0 when updating automation

This migration: 1. Updates contact_lists records with status='subscribed' -> 'active' 2. Updates automation nodes with status='subscribed' in their config -> 'active' 3. Updates contact_timeline changes JSON containing 'subscribed' -> 'active' 4. Recomputes automation stats from actual contact_automations data

func (*V26Migration) GetMajorVersion

func (m *V26Migration) GetMajorVersion() float64

func (*V26Migration) HasSystemUpdate

func (m *V26Migration) HasSystemUpdate() bool

func (*V26Migration) HasWorkspaceUpdate

func (m *V26Migration) HasWorkspaceUpdate() bool

func (*V26Migration) ShouldRestartServer

func (m *V26Migration) ShouldRestartServer() bool

func (*V26Migration) UpdateSystem

func (m *V26Migration) UpdateSystem(ctx context.Context, cfg *config.Config, db DBExecutor) error

func (*V26Migration) UpdateWorkspace

func (m *V26Migration) UpdateWorkspace(ctx context.Context, cfg *config.Config, workspace *domain.Workspace, db DBExecutor) error

Jump to

Keyboard shortcuts

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