migrations

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const HistoryTableName = "_auditLogMigrations"

HistoryTableName is the table tracking which migrations have been applied.

It is deliberately separate from PocketBase's own "_migrations" table: the host application's "migrate up/down/history-sync" commands operate on that one, and sharing it would let them revert or forget the plugin's migrations.

Variables

This section is empty.

Functions

func Register

func Register(id string, up, down func(txApp core.App) error)

Register adds a migration to the list applied by Run.

The id is stored as-is in the history table and defines the apply order, so it must keep the timestamp prefix and never change once the migration has shipped in a release. Passing it explicitly, instead of deriving it from the file name, means renaming the file cannot silently re-apply the migration.

Registering the same id twice panics, and down may be nil for migrations that cannot be reverted.

func Revert

func Revert(app core.App, count int) error

Revert rolls back the last count applied migrations, most recent first, and removes them from the history table.

It exists so the plugin can be uninstalled cleanly; nothing calls it during a normal boot.

func Run

func Run(app core.App) error

Run applies every registered migration that is not recorded in the history table yet, in id order.

All pending migrations run inside a single transaction, so a failure leaves the schema exactly as it was. It is safe to call on every boot: with nothing pending it costs one select.

Types

This section is empty.

Jump to

Keyboard shortcuts

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