Skip to content

Improve logging and add guardrails for seed/dev scripts #523

@diyor28

Description

@diyor28

Problem

Our seed / dev scripts are currently too easy to misuse and provide poor feedback when something goes wrong. This leads to confusion (e.g., running seeds against a restored backup or wrong environment) and time wasted debugging.

Goals

  1. Human-friendly logging

    • Clear, structured logs for each step (connect DB, migrate, truncate, seed entities, etc.).
    • Highlight key context at startup: environment, DB host/name/user, schema, app version/commit (if available).
    • Distinguish INFO/WARN/ERROR and show actionable messages.
  2. Guardrails / “fool-proof” behavior

    • Hard checks to prevent running destructive operations on non-dev environments.
    • Detect and warn/abort when targeting:
      • production / staging DBs
      • non-local hosts (unless explicitly allowed)
      • databases with large row counts / existing non-empty critical tables (configurable)
    • Require explicit confirmation for dangerous actions (truncate/reset) via:
      • --yes flag OR
      • interactive prompt (only if TTY)
    • Provide a dry-run mode (--dry-run) showing what would be executed.
  3. Better CLI UX

    • Consistent flags and help output.
    • Exit codes that CI/dev tooling can rely on.

Acceptance Criteria

  • Running the seed/dev scripts prints a concise, readable summary of what it will do and where.
  • By default, scripts refuse to run destructive actions outside dev/local contexts.
  • A user can override safeguards intentionally via explicit flags (documented).
  • Logs include enough context to understand failures without digging into code.
  • Documentation updated (README / docs) with examples.

Notes / Suggestions

  • Consider using a structured logger (zap/zerolog/slog) with pretty console output in dev.
  • Consider centralizing config validation/guard logic so all scripts share the same safety checks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions