Adjusted the migrations so they work on the prod db
This commit is contained in:
37
MIGRATION_RESET.md
Normal file
37
MIGRATION_RESET.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# 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())
|
||||
"
|
||||
```
|
||||
Reference in New Issue
Block a user