ワンクリックで
db-migrations
How to add or modify the devctl SQLite schema using goose SQL migrations and regenerate type-safe queries with sqlc
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
How to add or modify the devctl SQLite schema using goose SQL migrations and regenerate type-safe queries with sqlc
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
How to write and run devctl integration tests — where tests live, how to write failing tests first (TDD), and how to run them safely inside an Incus container without touching live host data.
Full workflow for tagging and publishing a devctl release and/or a PHP binaries release — versioning, release note generation from TODO.md, clearing TODO.md completed items, and the exact git/GitHub CLI steps for each release type.
How to add a new CLI command to devctl — writing the Cmd struct, registering it with init(), adding Client methods, using output helpers, and documenting it in README.md
How to add a new dashboard screenshot for a new or existing feature — wiring up scripts/screenshots.js, seeding data into the demo container via scripts/demo.sh, and adding the image reference to the README.
How to create, update, or maintain agent skills for this project — file structure, frontmatter rules, naming constraints, and where OpenCode discovers them
Full workflow for picking up and completing a TODO item from TODO.md — read the backlog, clarify, implement, install, browser-test, update docs, and move the item to Completed.
| name | db-migrations |
| description | How to add or modify the devctl SQLite schema using goose SQL migrations and regenerate type-safe queries with sqlc |
| license | MIT |
| compatibility | opencode |
| metadata | {"layer":"backend","concerns":"database, schema, sqlc, goose"} |
devctl uses SQLite (modernc.org/sqlite — pure Go, no CGO) with two complementary tools:
.sql filesLocation: db/migrations/
Current migrations:
001_sites.sql002_dumps.sql003_settings.sql004_site_settings.sql — adds settings TEXT NOT NULL DEFAULT '{}' to sites tableUse sequential integer prefixes with a descriptive snake_case suffix:
004_example_table.sql
Each migration file requires goose directive comments:
-- +goose Up
CREATE TABLE example (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
created_at DATETIME NOT NULL DEFAULT (datetime('now'))
);
-- +goose Down
DROP TABLE example;
Rules:
-- +goose Down block (even if it's just DROP TABLE).TEXT for UUIDs and JSON arrays (SQLite has no native UUID or array type).INTEGER NOT NULL DEFAULT 0 for booleans.DATETIME NOT NULL DEFAULT (datetime('now')) for timestamps.Migrations are applied automatically at startup — db/db.go calls goose.Up with the embedded migration files every time devctl starts. You never need to run migrations manually in production; just restart the service.
The make db-migrate target exists only as a development convenience (e.g. to apply a migration while iterating without restarting the service):
make db-migrate
# equivalent: /home/daniel/go/bin/goose -dir db/migrations sqlite3 /etc/devctl/devctl.db up
# NOTE: uses full goose path — sudo strips $PATH, so the Makefile uses the absolute path
Location of source SQL: db/queries/
Location of generated Go: db/queries/ (same dir, .go files)
.sql file in db/queries/ (e.g. example.sql).-- name: GetExample :one
SELECT * FROM example WHERE id = ? LIMIT 1;
-- name: ListExamples :many
SELECT * FROM example ORDER BY created_at DESC;
-- name: CreateExample :exec
INSERT INTO example (id, name, created_at) VALUES (?, ?, ?);
-- name: DeleteExample :exec
DELETE FROM example WHERE id = ?;
make sqlc
# equivalent: cd db && sqlc generate
This updates db/queries/models.go and the corresponding *_sql.go file.
s.queries on *api.Server is a *dbq.Queries. All generated methods are available on it:
row, err := s.queries.GetExample(r.Context(), id)
rows, err := s.queries.ListExamples(r.Context())
err = s.queries.CreateExample(r.Context(), dbq.CreateExampleParams{
ID: uuid.NewString(),
Name: "foo",
CreatedAt: time.Now().UTC().Format(time.RFC3339),
})
db/migrations/db/queries/make sqlc to regenerate Go typesmake db-migrate against the dev DB (/etc/devctl/devctl.db)