Documentation
¶
Index ¶
- Constants
- Variables
- type ConsumerOffsetsMigration
- 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 ¶
const RuleAuthenticated = "@request.auth.id != ''"
RuleAuthenticated restricts access to authenticated PocketBase users.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type ConsumerOffsetsMigration ¶ added in v0.0.3
type ConsumerOffsetsMigration struct{}
ConsumerOffsetsMigration creates the consumer_offsets collection for tracking consumer progress.
func (*ConsumerOffsetsMigration) Down ¶ added in v0.0.3
func (m *ConsumerOffsetsMigration) Down(ctx context.Context, client pbclient.AuthenticatedClient) error
func (*ConsumerOffsetsMigration) Name ¶ added in v0.0.3
func (m *ConsumerOffsetsMigration) Name() string
func (*ConsumerOffsetsMigration) Up ¶ added in v0.0.3
func (m *ConsumerOffsetsMigration) Up(ctx context.Context, client pbclient.AuthenticatedClient) error
type Migration ¶
type Migration interface {
Name() string
Up(ctx context.Context, client pbclient.AuthenticatedClient) error
Down(ctx context.Context, client pbclient.AuthenticatedClient) 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.
func NewConsumerOffsetsMigration ¶ added in v0.0.3
func NewConsumerOffsetsMigration() Migration
NewConsumerOffsetsMigration creates a new consumer offsets migration instance.
type Option ¶
type Option func(*Runner)
Option configures the Runner.
func WithAppName ¶ added in v0.0.3
WithAppName sets the application name for multi-app migration tracking. When set, migrations will be filtered by appname.
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"`
AppName string `json:"appname"`
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 NewRunner ¶
func NewRunner(client pbclient.AuthenticatedClient, opts ...Option) *Runner
NewRunner constructs a Runner with optional configuration.
func (*Runner) RegisterAll ¶
RegisterAll adds multiple migrations in order.