switchpart #62

Merged
amigan merged 2 commits from switchpart into trunk 2024-12-01 17:26:11 -05:00
3 changed files with 7 additions and 12 deletions
Showing only changes of commit 49ef99d193 - Show all commits

View file

@ -11,7 +11,6 @@ import (
"dynatron.me/x/stillbox/pkg/database/partman"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgconn"
"github.com/urfave/cli/v2"
)
@ -54,11 +53,6 @@ func partitioningCommand(cfg *config.Config) *cli.Command {
}
func Repartition(ctx context.Context, db database.Store, cfg config.Partition) error {
cfgIntv := partman.Interval(cfg.Interval)
if !cfgIntv.IsValid() {
return fmt.Errorf("invalid partitioning interval '%s'", string(cfgIntv))
}
pm, err := partman.New(db, cfg)
if err != nil {
return err
@ -86,14 +80,12 @@ func Repartition(ctx context.Context, db database.Store, cfg config.Partition) e
}
}
if cfgIntv == intv {
fmt.Fprintf(os.Stderr, "config interval '%s' and all extant, attached partitions agree; doing nothing\n", string(cfgIntv))
if pm.Interval() == intv {
fmt.Fprintf(os.Stderr, "config interval '%s' and all extant, attached partitions agree; doing nothing\n", string(pm.Interval()))
return nil
}
panic("not implemented")
return nil
}, pgx.TxOptions{})
}

View file

@ -93,6 +93,7 @@ func (p Interval) IsValid() bool {
type PartitionManager interface {
Go(ctx context.Context)
Check(ctx context.Context, now time.Time) error
Interval() Interval
ExistingPartitions(parts []database.PartitionResult) ([]Partition, error)
}
@ -102,6 +103,10 @@ type partman struct {
intv Interval
}
func (pm *partman) Interval() Interval {
return pm.intv
}
type Partition struct {
ParentTable string
Schema string

View file

@ -161,5 +161,3 @@ CREATE TABLE IF NOT EXISTS incidents_calls(
FOREIGN KEY (calls_tbl_id, call_date) REFERENCES calls(id, call_date),
PRIMARY KEY (incident_id, call_id)
);