Documentation
¶
Index ¶
- Variables
- type Migration
- type Option
- type PBTime
- type Record
- type Runner
- func (r *Runner) Applied(ctx context.Context) ([]Record, error)
- func (r *Runner) Down(ctx context.Context, n int) error
- func (r *Runner) Pending(ctx context.Context) ([]Migration, error)
- func (r *Runner) Register(m Migration) error
- func (r *Runner) RegisterAll(migrations ...Migration) error
- func (r *Runner) Run(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Migration ¶
type Migration interface {
Name() string
Up(client *pbclient.Client) error
Down(client *pbclient.Client) error
}
Migration defines a reversible change applied through PocketBase using pbclient. Implementations must return a stable, sortable name (e.g. 20250121_add_users) and provide Up/Down hooks that perform the forward and rollback work.
type Option ¶
type Option func(*Runner)
Option configures the Runner.
func WithAutoCreate ¶
WithAutoCreate controls whether the migrations collection is created automatically when missing. Defaults to true.
func WithCollectionName ¶
WithCollectionName overrides the default migrations log collection name.
func WithLogCollectionName ¶
WithLogCollectionName overrides the default migrations log collection name. Alias for WithCollectionName for clarity.
type PBTime ¶
PBTime handles the PocketBase datetime format returned by the API (with a space instead of T).
func (PBTime) MarshalJSON ¶
func (*PBTime) UnmarshalJSON ¶
type Record ¶
type Record struct {
ID string `json:"id"`
Name string `json:"name"`
AppliedAt PBTime `json:"applied_at"`
}
Record stores bookkeeping data for applied migrations inside PocketBase.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner executes registered migrations against PocketBase and records progress.
func (*Runner) RegisterAll ¶
RegisterAll adds multiple migrations in order.