gcfm

module
v0.0.0-...-b25413d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2025 License: MIT

README ΒΆ

go-custom-field-model (GCFM)

Docs CI Go Report Card codecov License

go-custom-field-model (GCFM) is a Go framework that automates custom field management on RDBs and NoSQL databases. It provides:

  • CLI (fieldctl) β€” schema scanning, drift detection, and YAML registry operations
  • SDK (sdk) β€” Go API for embedding in applications
  • API Server (api-server) β€” exposes a REST API and integrates with gcfm-dashboard

✨ Features

  • Schema Scan β€” automatically detects database schemas and records metadata
  • YAML Registry β€” manages custom field definitions in versioned YAML
  • Diff & Apply β€” detects schema drift and applies differences
  • Multi-Tenant β€” manages a meta database and multiple target databases
  • Extensible β€” extend validators via Go plugins
  • Observability β€” Prometheus metrics and a CI drift guard
  • Dashboard UI β€” operate from the separate gcfm-dashboard repository

πŸš€ Quick Start

1. Build
make build   # builds the CLI and API server (outputs to bin/)
2. Initialize DB
bin/fieldctl db migrate \
  --table-prefix="gcfm_" \
  --db "root:rootpw@tcp(localhost:3306)/gcfm" \
  --schema public \
  --seed \
  --driver=mysql
3. Start API Server
bin/api-server -addr=:18081 --driver=mysql --dsn "root:rootpw@tcp(localhost:3306)/gcfm"

πŸ“· CLI Examples

Scan existing database
$ fieldctl scan --db "postgres://user:pass@localhost:5432/app" \
    --schema public --driver postgres
INSERT 8  UPDATE 2  SKIP 3 (reserved)
Show drift between DB and registry.yaml
$ fieldctl diff --db "postgres://user:pass@localhost:5432/app" \
    --schema public --driver postgres --file registry.yaml --fail-on-change

--- posts.title (DB)
+++ posts.title (YAML)
- type: varchar(255)
+ type: text
Apply registry.yaml (dry-run)
$ fieldctl apply --db "postgres://user:pass@localhost:5432/app" \
    --schema public --file registry.yaml --dry-run

[DRY-RUN] Would ALTER COLUMN posts.title TYPE text

πŸ–₯ Dashboard Example

By using gcfm-dashboard, you can manage fields from the browser.

Dashboard Screenshot


πŸ“š Documentation

πŸ‘‰ See docs/index.md for details.


πŸ“¦ Package Layout

  • sdk/ β€” public SDK
  • internal/ β€” server implementation
  • pkg/ β€” shared utilities
  • cmd/fieldctl/ β€” CLI tool

🀝 Contributing

We welcome pull requests, issues, and feature proposals. See CONTRIBUTING.md for details.


πŸ“„ License

MIT License

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL