Skip to content
Back to skills

Db Workflow

ASecurity

Database migration workflow helper. Use when creating database migrations, modifying SQLAlchemy models, or managing Alembic migrations. Automatically handles model changes, migration creation, and database upgrades.

  • 666 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added February 8, 2026
databasesbashsqldockerdatabasebackendsecurity

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill db-workflow --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Db Workflow?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Db Workflow
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-db-workflow/badge)](https://www.skillsdirectory.com/skills/majiayu000-db-workflow)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: db-workflow
description: Database migration workflow helper. Use when creating database migrations, modifying SQLAlchemy models, or managing Alembic migrations. Automatically handles model changes, migration creation, and database upgrades.
---

# Database Migration Workflow

This skill helps with the complete database migration workflow in this project.

## When to use this skill

- Modifying SQLAlchemy models in `backend/app/models/`
- Creating new database tables or columns
- Changing relationships between models
- Running database migrations
- Checking migration status

## Workflow Steps

1. **Before modifying models**: Check current migration status
   ```bash
   make db-upgrade  # Ensure all migrations are applied
   ```

2. **After modifying models**: Create migration
   ```bash
   make db-migrate  # Auto-generate migration from model changes
   ```

3. **Review migration**: Always read the generated migration file in `backend/alembic/versions/`
   - Verify upgrade() and downgrade() operations
   - Check for data migrations if needed
   - Ensure no data loss operations

4. **Apply migration**:
   ```bash
   make db-upgrade  # Apply to local database
   ```

5. **Test migration**: Run tests to verify schema changes
   ```bash
   make test
   ```

## Critical Rules

- NEVER delete the Docker volume `pgdata` - local database must persist
- Always review auto-generated migrations before applying
- Test both upgrade AND downgrade paths
- For production: coordinate with team before running migrations
- Row-level security (RLS) policies may need manual updates in migrations

## Common Tasks

### Add new model field
1. Add field to SQLAlchemy model
2. Run `make db-migrate`
3. Review generated migration
4. Run `make db-upgrade`
5. Run `make test`

### Create new table
1. Create new model class in appropriate module
2. Import model in `backend/app/models/__init__.py`
3. Run `make db-migrate`
4. Review generated migration
5. Run `make db-upgrade`
6. Run `make test`

### Check migration status
```bash
cd backend
uv run alembic current     # Show current revision
uv run alembic heads       # Show latest revision
uv run alembic history     # Show all migrations
```

## Troubleshooting

- **Migration conflict**: Multiple heads exist, merge with `alembic merge`
- **Auto-generation missed changes**: Check model imports and table metadata
- **Test database issues**: Use `DATABASE_URL="postgresql://postgres:postgres@localhost:5433/manageros_test" make db-upgrade`

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.