.agents/skills/database/SKILL.md
Understand onepixel database topology by environment, data ownership across app/events stores, and initialization/migration behavior.
npx skillsauth add championswimmer/onepixel_backend databaseInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use this skill when changing config, models, controllers, or test setup that touches persistence.
onepixel.local.env):
sqlite (DB_DIALECT=sqlite, DATABASE_URL=app.db)duckdb (EVENTDB_DIALECT=duckdb, EVENTDB_URL=events.db)USE_FILE_DB=true enables file-backed providers.ENV=test + onepixel.test.env):
sqlite (app.db)duckdb (events.db)onepixel_backend/tests/providers to inject test DB providers.onepixel.production.env):
USE_FILE_DB=false enables network DB providers.postgres (DB_DIALECT=postgres).postgres by default because COMMON_APP_EVENT_DB=true and EVENTDB_DIALECT=postgres.clickhouse for events when EVENTDB_DIALECT=clickhouse and COMMON_APP_EVENT_DB=false.users (models.User)url_groups (models.UrlGroup)urls (models.Url)events_redirect (models.EventRedirect)./GeoLite2-City.mmdb), opened by db.GetGeoIPDB() for enrichment; not managed by GORM migrations.src/db/init.go:
GetAppDB, GetEventsDB, and GetGeoIPDB each guarded by sync.Once.src/main.go eagerly initializes all three DB clients.db.init() based on config.UseFileDB:
sqlite, duckdbpostgres, clickhousesrc/db/providers.go:
postgres/clickhouse open with retry (attemptToOpen, 10 attempts with 1s delay).sqlite/duckdb open directly.AutoMigrate in src/db/init.go.GetAppDB):
User, UrlGroup, Url.lo.Must0), so startup/first access fails fast.GetEventsDB):
EventRedirect.lo.TryWithErrorValue + applogger.Error).tests/providers/test_db_providers.go overrides sqlite and duckdb providers via db.InjectDBProvider._ "onepixel_backend/tests/providers").make test_clean removes app.db and events.db before each test suite target.ENV=test also changes cwd to repo root in src/config/env.go, ensuring relative DB paths resolve consistently.testing
Run onepixel unit and e2e tests with correct env setup, coverage artifacts, and troubleshooting guidance for GeoIP/network-related failures.
development
Apply onepixel repository conventions for env loading, DB backend selection, auth locals, error payloads, and shortcode semantics.
development
Build and run onepixel binaries, generate Swagger docs when needed, and produce cross-platform release artifacts.
data-ai
Understand onepixel runtime architecture, host-based app dispatch, and redirect analytics flow before changing behavior across routes/controllers/db.