feat(admin): documents, indexes and the plan seed

Adds admin's own documents, its unique indexes and the plan seed from
shared/license.

Licences are append-only -- a renewal writes a new row and supersedes the
old one -- because the history is the support tool. Plans are seeded with
$setOnInsert only, so a redeploy never stamps over staff edits to limits,
features or Paddle IDs.

admin_instances.instance_id unique is a correctness property, not an
optimisation: without it two customers could both claim one self-hosted
UUID and both be issued licences for it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
mrhid6
2026-07-25 19:00:37 +01:00
co-authored by Claude Opus 5
parent 64eac6dbc7
commit b8fcf89ee7
6 changed files with 289 additions and 0 deletions
+12
View File
@@ -13,6 +13,7 @@ import (
"github.com/joho/godotenv"
"github.com/mrhid6/vantage/admin/internal/config"
"github.com/mrhid6/vantage/admin/internal/db"
"github.com/mrhid6/vantage/admin/internal/models"
)
func main() {
@@ -31,6 +32,17 @@ func main() {
cancel()
log.Printf("connected: admin=%s control=%s", cfg.AdminDBName, cfg.ControlDBName)
idxCtx, idxCancel := context.WithTimeout(context.Background(), 30*time.Second)
if err := db.EnsureIndexes(idxCtx); err != nil {
idxCancel()
log.Fatalf("indexes: %v", err)
}
if err := models.SeedPlans(idxCtx); err != nil {
idxCancel()
log.Fatalf("plan seed: %v", err)
}
idxCancel()
srv := &http.Server{
Addr: cfg.Addr,
Handler: http.NotFoundHandler(), // replaced in Task 8