postgres

package
v0.0.0-...-1af8dc6 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package postgres provides the PostgreSQL adapter for IntegriDB.

Index

Constants

View Source
const (
	// SchemaVersion is the current schema version for migration tracking.
	SchemaVersion = 1

	// CreateEventsTableSQL creates the integridb_events table.
	CreateEventsTableSQL = `` /* 381-byte string literal not displayed */

	// CreateEventsIndexSQL creates indexes for efficient event lookup.
	CreateEventsIndexSQL = `` /* 356-byte string literal not displayed */

	// CreateTrackedTablesSQL creates the integridb_tracked_tables registry.
	CreateTrackedTablesSQL = `` /* 251-byte string literal not displayed */

	// CreateSchemaVersionSQL creates the schema version tracking table.
	CreateSchemaVersionSQL = `` /* 148-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func MigrationSQL

func MigrationSQL() []string

MigrationSQL returns the SQL statements to create the IntegriDB schema.

Types

type PostgresAdapter

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

PostgresAdapter implements event storage for PostgreSQL.

func NewPostgresAdapter

func NewPostgresAdapter(db *sql.DB) *PostgresAdapter

NewPostgresAdapter creates a new PostgreSQL adapter.

func (*PostgresAdapter) Close

func (a *PostgresAdapter) Close() error

Close closes the database connection.

func (*PostgresAdapter) GetEventByID

func (a *PostgresAdapter) GetEventByID(ctx context.Context, eventID string) (*event.Event, error)

GetEventByID retrieves a specific event by its ID.

func (*PostgresAdapter) GetEvents

func (a *PostgresAdapter) GetEvents(ctx context.Context, tableName, rowID string) ([]*event.Event, error)

GetEvents retrieves all events for a specific table and row, ordered by version.

func (*PostgresAdapter) GetEventsByTable

func (a *PostgresAdapter) GetEventsByTable(ctx context.Context, tableName string) ([]*event.Event, error)

GetEventsByTable retrieves all events for a table, ordered by row_id and version.

func (*PostgresAdapter) GetLastEvent

func (a *PostgresAdapter) GetLastEvent(ctx context.Context, tableName, rowID string) (*event.Event, error)

GetLastEvent retrieves the most recent event for a specific row.

func (*PostgresAdapter) GetTrackedTable

func (a *PostgresAdapter) GetTrackedTable(ctx context.Context, tableName string) (*TrackedTableInfo, error)

GetTrackedTable retrieves a specific tracked table from the registry.

func (*PostgresAdapter) GetTrackedTables

func (a *PostgresAdapter) GetTrackedTables(ctx context.Context) ([]TrackedTableInfo, error)

GetTrackedTables retrieves all tracked tables from the registry.

func (*PostgresAdapter) InsertEvent

func (a *PostgresAdapter) InsertEvent(ctx context.Context, event *event.Event) error

InsertEvent persists a new event to the event store.

func (*PostgresAdapter) Migrate

func (a *PostgresAdapter) Migrate(ctx context.Context) error

Migrate creates the IntegriDB schema tables if they don't exist. This operation is idempotent and safe to run multiple times.

func (*PostgresAdapter) RegisterTrackedTable

func (a *PostgresAdapter) RegisterTrackedTable(ctx context.Context, tableName string, primaryKey []string) error

RegisterTrackedTable records a table in the tracked tables registry.

func (*PostgresAdapter) UnregisterTrackedTable

func (a *PostgresAdapter) UnregisterTrackedTable(ctx context.Context, tableName string) error

UnregisterTrackedTable removes a table from the tracked tables registry.

func (*PostgresAdapter) UpdateLastEvent

func (a *PostgresAdapter) UpdateLastEvent(ctx context.Context, tableName, eventID string, eventTime time.Time) error

UpdateLastEvent updates the last event information for a tracked table.

type TrackedTableInfo

type TrackedTableInfo struct {
	TableName         string
	PrimaryKeyColumns []string
	LastEventID       *string
	LastEventAt       *time.Time
}

TrackedTableInfo contains metadata about a tracked table.

Jump to

Keyboard shortcuts

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