Files
alpinebits_python/MIGRATION_RESET.md
2025-11-19 19:10:25 +01:00

37 lines
1.0 KiB
Markdown

# Migration Reset Instructions
If you need to reset the alembic_version table to start migrations from scratch:
## SQL Command
```sql
-- Connect to your database and run:
DELETE FROM alpinebits.alembic_version;
```
This clears all migration records so that `alembic upgrade head` will run all migrations from the beginning.
## Python One-Liner (if preferred)
```bash
uv run python -c "
import asyncio
from sqlalchemy import text
from alpine_bits_python.config_loader import load_config
from alpine_bits_python.db import get_database_url, get_database_schema
from sqlalchemy.ext.asyncio import create_async_engine
async def reset():
app_config = load_config()
db_url = get_database_url(app_config)
schema = get_database_schema(app_config)
engine = create_async_engine(db_url)
async with engine.begin() as conn:
await conn.execute(text(f'SET search_path TO {schema}'))
await conn.execute(text('DELETE FROM alembic_version'))
print('Cleared alembic_version table')
await engine.dispose()
asyncio.run(reset())
"
```