Database Workflow Bundle
Overview
Use this skill to review, plan, or guide database work that may affect:
- data correctness
- schema compatibility
- migration safety
- query performance
- operational reliability
- backup and restore readiness
- stateful runtime behavior in containers or Kubernetes
This skill is for database change analysis and operational review, not for blind execution. Use it when the task requires judgment across application code, schema or model changes, migration order, runtime behavior, and rollback risk.
If this copy came from an imported upstream workflow, preserve provenance markers, copied support files, and origin notes unless the user explicitly asks for cleanup.
When to Use
Activate this skill when the request includes one or more of the following:
- SQL schema changes, indexes, constraints, views, or query rewrites
- NoSQL collection or document model changes
- migration creation, ordering, rollback, or drift review
- slow query investigation or execution-plan review
- backup, restore, retention, or recovery-readiness checks
- database deployment in Docker, Kubernetes, or other stateful runtimes
- data pipeline or batch-load changes that can affect integrity or performance
Do not use this skill as the primary workflow when the task is only:
- basic CRUD application coding with no schema or runtime impact
- generic infrastructure work unrelated to persistence
- pure analytics or BI interpretation with no database design or operations decision
Activation Boundary
Before doing deep review, confirm these inputs:
- Engine and version: PostgreSQL, MySQL-compatible, MongoDB, or another named engine.
- Change type: schema/model, migration, query, operational config, restore, or performance issue.
- Execution context: local dev, CI, production, managed service, container, or Kubernetes.
- Risk surface: destructive DDL, backfill, lock risk, storage change, credential handling, or restore dependency.
- Evidence available: migration files, schema diff, EXPLAIN output, logs, manifests, backup procedure, or incident symptoms.
If the request does not provide these, ask for them before approving or proposing high-risk changes.
Workflow
Classify the database task
- Identify the engine, version, workload type, and whether the change is relational, document-oriented, or runtime-operational.
- Separate design review from execution review. A good schema idea can still be unsafe to deploy.
Map the change surface
- List all touched artifacts: schema files, migrations, ORM models, queries, indexes, manifests, secrets references, backup jobs, restore docs, or pipeline configs.
- Check whether application code and database changes are coupled and require ordering.
Review correctness and compatibility
- For relational systems, check keys, nullability, uniqueness, foreign-key behavior, default values, and backward compatibility.
- For document databases, check document shape, validation rules, query paths, index coverage, and write amplification risk.
- Flag assumptions about existing data quality before recommending stricter constraints.
Review migration and rollout safety
- Identify destructive or locking operations: table rewrites, large index builds, column type changes, mass updates, or collection-wide rewrites.
- Require a deployment order when code depends on new columns, indexes, or document fields.
- Check for rollback reality. Many schema changes are only partially reversible once data has changed.
Review performance and operational evidence
- Use execution plans, index usage, cardinality assumptions, or query shape evidence instead of intuition.
- For runtime changes, inspect persistence settings, volume claims, storage classes, restart behavior, readiness, and backup integration.
- Confirm that maintenance operations such as analyze, vacuum, compaction, or statistics refresh are considered when relevant.
Review recovery and safety controls
- Check whether backup, restore, and retention expectations are named for the affected data.
- Verify credential handling, least-privilege access, and query safety controls.
- Reject changes that increase injection risk, hide destructive behavior, or assume untested restore paths.
Produce the decision
- Return one of: approve, approve with conditions, needs evidence, or unsafe as proposed.
- State the reason in engine-specific terms.
- List required follow-ups: test data validation, EXPLAIN output, migration split, restore rehearsal, or storage-class confirmation.
Review Focus by Domain
Relational databases
Prioritize:
- primary and foreign key integrity
- nullability and default semantics
- uniqueness and duplicate prevention
- online vs blocking DDL risk
- index selectivity and maintenance cost
- query plan evidence for performance claims
- data backfill ordering and idempotency
Document databases
Prioritize:
- document growth and update patterns
- required vs optional fields
- schema validation compatibility
- index support for actual query predicates and sort paths
- hot-document or hot-partition risk
- migration strategy for mixed old/new document shapes
Stateful runtime and Kubernetes
Prioritize:
- persistent volume usage instead of ephemeral storage for durable data
- StatefulSet identity and storage behavior
- storage class defaults and expansion behavior
- resource requests and restart behavior
- backup hooks, snapshots, or external backup integration
- readiness/liveness probes that do not corrupt or thrash the database
Examples
Example 1: SQL migration review
-- proposed migration
ALTER TABLE orders ADD COLUMN customer_email TEXT NOT NULL;
Expected review outcome:
- Status: needs evidence / unsafe as proposed
- Why: existing rows will violate
NOT NULL unless a valid backfill or default strategy exists
- Safer direction: add nullable column, backfill in controlled batches, validate data, then enforce
NOT NULL in a later migration
Example 2: Query optimization review
SELECT *
FROM events
WHERE account_id = 42
AND created_at >= NOW() - INTERVAL '7 days'
ORDER BY created_at DESC
LIMIT 100;
Expected review outcome:
- ask for
EXPLAIN or EXPLAIN ANALYZE
- verify whether an index supports both the filter and sort pattern
- avoid approving a rewrite based only on intuition or row-count guesses
Example 3: Document-model change review
{
"change": "Make profile.phone required for all user documents",
"current_state": "Field is missing in legacy documents",
"deployment": "Validation rule enabled immediately"
}
Expected review outcome:
- Status: unsafe as proposed
- Why: legacy documents and partial-write paths may fail immediately
- Safer direction: audit missing-field population, backfill, update writers and readers, then tighten validation
Example 4: Kubernetes storage review
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres
spec:
template:
spec:
containers:
- name: postgres
image: postgres:latest
volumeMounts:
- name: data
mountPath: /var/lib/postgresql/data
volumes:
- name: data
emptyDir: {}
Expected review outcome:
- Status: unsafe as proposed
- Why:
emptyDir is ephemeral and does not provide durable database storage
- Safer direction: require persistent storage and stateful deployment review before approval
For worked review samples, open:
examples/review-example.md
examples/troubleshooting-examples.md
Best Practices
Do:
- require engine-specific evidence before approving performance claims
- separate logical correctness from deployment safety
- ask how existing data will satisfy new constraints or validation rules
- review rollback feasibility, not just forward migration syntax
- confirm persistence, backup, and restore expectations for operational changes
- preserve provenance if this skill was imported from an upstream workflow
Do not:
- approve destructive DDL without data-shape and rollback analysis
- assume a new index is free; check write cost and storage impact
- treat document databases as schema-free in production review
- accept ephemeral storage for persistent database workloads
- recommend credential embedding, unsafe dynamic SQL, or unbounded bulk updates without safeguards
- claim a restore strategy exists unless restore steps and dependencies are testable
Troubleshooting
Symptoms: migration fails after adding a NOT NULL column or stricter constraint.
Solution: inspect existing rows first. Recommend a staged migration: add nullable structure, backfill safely, validate results, then enforce the constraint.
Symptoms: query is still slow after adding an index.
Solution: review the actual query plan. Check predicate order, sort requirements, row estimates, stale statistics, and whether the query shape matches the index.
Symptoms: deadlocks or blocked writes appear during deployment.
Solution: inspect migration ordering, lock scope, transaction size, and concurrent write paths. Split high-impact operations and avoid large blocking changes during peak load.
Symptoms: restore procedure completes, but the application still fails or data is incomplete.
Solution: verify dependent objects, credentials, extensions, point-in-time expectations, post-restore validation, and application version compatibility. A technically successful restore is not the same as a usable recovery.
Symptoms: database pod restarts and data disappears.
Solution: verify whether storage is ephemeral, whether the workload should be a StatefulSet, and whether persistent volume claims and storage classes are configured for durable state.
For condensed triage paths, open references/troubleshooting-matrix.md.
Additional Resources
references/review-criteria.md — open when you need a compact engine-aware checklist for schema, migration, performance, backup/restore, and Kubernetes storage review.
references/troubleshooting-matrix.md — open when the task starts from symptoms such as slow queries, deadlocks, failed restores, migration drift, or storage misconfiguration.
examples/review-example.md — open for a worked example of reviewing SQL, document-model, and storage-related changes.
examples/troubleshooting-examples.md — open for symptom-to-decision examples that show what a strong operator response looks like.
Output Template
Use this structure when reporting conclusions:
Decision: approve | approve with conditions | needs evidence | unsafe as proposed
Engine/runtime: <name and version if known>
Change type: <schema | migration | query | operational | restore | pipeline>
Primary risks:
- ...
Evidence reviewed:
- ...
Required follow-ups:
- ...
Reasoning:
- ...
Provenance Notes
If the skill was imported from an upstream repository:
- preserve origin markers and copied support files unless the user requests cleanup
- avoid rewriting provenance history during technical edits
- keep the review focused on the database workflow itself, not on hiding the import path
1---2name: database-v2-23description: Database Workflow Bundle workflow skill. Use this skill when the user needs database development and operations workflow covering SQL, NoSQL, database design, migrations, optimization, and data engineering, while preserving upstream workflow context, copied support files, and provenance before merge or handoff.4license: Unknown5---67# Database Workflow Bundle89## Overview1011Use this skill to review, plan, or guide database work that may affect:12- data correctness13- schema compatibility14- migration safety15- query performance16- operational reliability17- backup and restore readiness18- stateful runtime behavior in containers or Kubernetes1920This skill is for database change analysis and operational review, not for blind execution. Use it when the task requires judgment across application code, schema or model changes, migration order, runtime behavior, and rollback risk.2122If this copy came from an imported upstream workflow, preserve provenance markers, copied support files, and origin notes unless the user explicitly asks for cleanup.2324## When to Use2526Activate this skill when the request includes one or more of the following:27- SQL schema changes, indexes, constraints, views, or query rewrites28- NoSQL collection or document model changes29- migration creation, ordering, rollback, or drift review30- slow query investigation or execution-plan review31- backup, restore, retention, or recovery-readiness checks32- database deployment in Docker, Kubernetes, or other stateful runtimes33- data pipeline or batch-load changes that can affect integrity or performance3435Do **not** use this skill as the primary workflow when the task is only:36- basic CRUD application coding with no schema or runtime impact37- generic infrastructure work unrelated to persistence38- pure analytics or BI interpretation with no database design or operations decision3940## Activation Boundary4142Before doing deep review, confirm these inputs:431. **Engine and version:** PostgreSQL, MySQL-compatible, MongoDB, or another named engine.442. **Change type:** schema/model, migration, query, operational config, restore, or performance issue.453. **Execution context:** local dev, CI, production, managed service, container, or Kubernetes.464. **Risk surface:** destructive DDL, backfill, lock risk, storage change, credential handling, or restore dependency.475. **Evidence available:** migration files, schema diff, EXPLAIN output, logs, manifests, backup procedure, or incident symptoms.4849If the request does not provide these, ask for them before approving or proposing high-risk changes.5051## Workflow52531. **Classify the database task**54 - Identify the engine, version, workload type, and whether the change is relational, document-oriented, or runtime-operational.55 - Separate design review from execution review. A good schema idea can still be unsafe to deploy.56572. **Map the change surface**58 - List all touched artifacts: schema files, migrations, ORM models, queries, indexes, manifests, secrets references, backup jobs, restore docs, or pipeline configs.59 - Check whether application code and database changes are coupled and require ordering.60613. **Review correctness and compatibility**62 - For relational systems, check keys, nullability, uniqueness, foreign-key behavior, default values, and backward compatibility.63 - For document databases, check document shape, validation rules, query paths, index coverage, and write amplification risk.64 - Flag assumptions about existing data quality before recommending stricter constraints.65664. **Review migration and rollout safety**67 - Identify destructive or locking operations: table rewrites, large index builds, column type changes, mass updates, or collection-wide rewrites.68 - Require a deployment order when code depends on new columns, indexes, or document fields.69 - Check for rollback reality. Many schema changes are only partially reversible once data has changed.70715. **Review performance and operational evidence**72 - Use execution plans, index usage, cardinality assumptions, or query shape evidence instead of intuition.73 - For runtime changes, inspect persistence settings, volume claims, storage classes, restart behavior, readiness, and backup integration.74 - Confirm that maintenance operations such as analyze, vacuum, compaction, or statistics refresh are considered when relevant.75766. **Review recovery and safety controls**77 - Check whether backup, restore, and retention expectations are named for the affected data.78 - Verify credential handling, least-privilege access, and query safety controls.79 - Reject changes that increase injection risk, hide destructive behavior, or assume untested restore paths.80817. **Produce the decision**82 - Return one of: approve, approve with conditions, needs evidence, or unsafe as proposed.83 - State the reason in engine-specific terms.84 - List required follow-ups: test data validation, EXPLAIN output, migration split, restore rehearsal, or storage-class confirmation.8586## Review Focus by Domain8788### Relational databases8990Prioritize:91- primary and foreign key integrity92- nullability and default semantics93- uniqueness and duplicate prevention94- online vs blocking DDL risk95- index selectivity and maintenance cost96- query plan evidence for performance claims97- data backfill ordering and idempotency9899### Document databases100101Prioritize:102- document growth and update patterns103- required vs optional fields104- schema validation compatibility105- index support for actual query predicates and sort paths106- hot-document or hot-partition risk107- migration strategy for mixed old/new document shapes108109### Stateful runtime and Kubernetes110111Prioritize:112- persistent volume usage instead of ephemeral storage for durable data113- StatefulSet identity and storage behavior114- storage class defaults and expansion behavior115- resource requests and restart behavior116- backup hooks, snapshots, or external backup integration117- readiness/liveness probes that do not corrupt or thrash the database118119## Examples120121### Example 1: SQL migration review122123```sql124-- proposed migration125ALTER TABLE orders ADD COLUMN customer_email TEXT NOT NULL;126```127128Expected review outcome:129- **Status:** needs evidence / unsafe as proposed130- **Why:** existing rows will violate `NOT NULL` unless a valid backfill or default strategy exists131- **Safer direction:** add nullable column, backfill in controlled batches, validate data, then enforce `NOT NULL` in a later migration132133### Example 2: Query optimization review134135```sql136SELECT *137FROM events138WHERE account_id = 42139 AND created_at >= NOW() - INTERVAL '7 days'140ORDER BY created_at DESC141LIMIT 100;142```143144Expected review outcome:145- ask for `EXPLAIN` or `EXPLAIN ANALYZE`146- verify whether an index supports both the filter and sort pattern147- avoid approving a rewrite based only on intuition or row-count guesses148149### Example 3: Document-model change review150151```json152{153 "change": "Make profile.phone required for all user documents",154 "current_state": "Field is missing in legacy documents",155 "deployment": "Validation rule enabled immediately"156}157```158159Expected review outcome:160- **Status:** unsafe as proposed161- **Why:** legacy documents and partial-write paths may fail immediately162- **Safer direction:** audit missing-field population, backfill, update writers and readers, then tighten validation163164### Example 4: Kubernetes storage review165166```yaml167apiVersion: apps/v1168kind: Deployment169metadata:170 name: postgres171spec:172 template:173 spec:174 containers:175 - name: postgres176 image: postgres:latest177 volumeMounts:178 - name: data179 mountPath: /var/lib/postgresql/data180 volumes:181 - name: data182 emptyDir: {}183```184185Expected review outcome:186- **Status:** unsafe as proposed187- **Why:** `emptyDir` is ephemeral and does not provide durable database storage188- **Safer direction:** require persistent storage and stateful deployment review before approval189190For worked review samples, open:191- `examples/review-example.md`192- `examples/troubleshooting-examples.md`193194## Best Practices195196Do:197- require engine-specific evidence before approving performance claims198- separate logical correctness from deployment safety199- ask how existing data will satisfy new constraints or validation rules200- review rollback feasibility, not just forward migration syntax201- confirm persistence, backup, and restore expectations for operational changes202- preserve provenance if this skill was imported from an upstream workflow203204Do not:205- approve destructive DDL without data-shape and rollback analysis206- assume a new index is free; check write cost and storage impact207- treat document databases as schema-free in production review208- accept ephemeral storage for persistent database workloads209- recommend credential embedding, unsafe dynamic SQL, or unbounded bulk updates without safeguards210- claim a restore strategy exists unless restore steps and dependencies are testable211212## Troubleshooting213214**Symptoms:** migration fails after adding a `NOT NULL` column or stricter constraint.215216**Solution:** inspect existing rows first. Recommend a staged migration: add nullable structure, backfill safely, validate results, then enforce the constraint.217218**Symptoms:** query is still slow after adding an index.219220**Solution:** review the actual query plan. Check predicate order, sort requirements, row estimates, stale statistics, and whether the query shape matches the index.221222**Symptoms:** deadlocks or blocked writes appear during deployment.223224**Solution:** inspect migration ordering, lock scope, transaction size, and concurrent write paths. Split high-impact operations and avoid large blocking changes during peak load.225226**Symptoms:** restore procedure completes, but the application still fails or data is incomplete.227228**Solution:** verify dependent objects, credentials, extensions, point-in-time expectations, post-restore validation, and application version compatibility. A technically successful restore is not the same as a usable recovery.229230**Symptoms:** database pod restarts and data disappears.231232**Solution:** verify whether storage is ephemeral, whether the workload should be a StatefulSet, and whether persistent volume claims and storage classes are configured for durable state.233234For condensed triage paths, open `references/troubleshooting-matrix.md`.235236## Additional Resources237238- `references/review-criteria.md` — open when you need a compact engine-aware checklist for schema, migration, performance, backup/restore, and Kubernetes storage review.239- `references/troubleshooting-matrix.md` — open when the task starts from symptoms such as slow queries, deadlocks, failed restores, migration drift, or storage misconfiguration.240- `examples/review-example.md` — open for a worked example of reviewing SQL, document-model, and storage-related changes.241- `examples/troubleshooting-examples.md` — open for symptom-to-decision examples that show what a strong operator response looks like.242243## Output Template244245Use this structure when reporting conclusions:246247```text248Decision: approve | approve with conditions | needs evidence | unsafe as proposed249Engine/runtime: <name and version if known>250Change type: <schema | migration | query | operational | restore | pipeline>251Primary risks:252- ...253Evidence reviewed:254- ...255Required follow-ups:256- ...257Reasoning:258- ...259```260261## Provenance Notes262263If the skill was imported from an upstream repository:264- preserve origin markers and copied support files unless the user requests cleanup265- avoid rewriting provenance history during technical edits266- keep the review focused on the database workflow itself, not on hiding the import path