# Conflicts: # docs/data/generated/dev-docs.json # internal/app/archied/state_store_pool.go
32 lines
1.0 KiB
Go
32 lines
1.0 KiB
Go
package postgres
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/jackc/pgx/v5/pgxpool"
|
|
|
|
"github.com/samcharles93/archie-core/internal/infrastructure/postgres/postgresdb"
|
|
)
|
|
|
|
// ImportComplete reports whether the one-time legacy import committed and
|
|
// verified against this migrated database. Serving over non-empty legacy
|
|
// files is refused without it.
|
|
func ImportComplete(ctx context.Context, pool *pgxpool.Pool) (bool, error) {
|
|
done, err := postgresdb.New(pool).ImportCompleted(ctx)
|
|
if err != nil {
|
|
return false, fmt.Errorf("postgres: import completion: %w", err)
|
|
}
|
|
return done, nil
|
|
}
|
|
|
|
// RecordFreshInstall writes the completion record for a database that starts
|
|
// with no legacy data to import, so a legacy file that appears later cannot
|
|
// block it from serving. It leaves an existing record untouched.
|
|
func RecordFreshInstall(ctx context.Context, pool *pgxpool.Pool) error {
|
|
if err := postgresdb.New(pool).InsertFreshInstallCompletion(ctx); err != nil {
|
|
return fmt.Errorf("postgres: fresh install completion: %w", err)
|
|
}
|
|
return nil
|
|
}
|