dstack uses Alembic to manage database migrations. If you modify any SQLAlchemy
models or related data structures,
generate a new migration with Alembic:
cd src/dstack/_internal/server/
alembic revision -m "<some message>" --autogenerateThen adjust the generated migration if needed.
If you modify any enums used in SQLAlchemy models, you will need to set up PostgreSQL in order to generate a PostgreSQL-specific enum migration.
-
Run PostgreSQL.
docker run --rm -p 5432:5432 -e POSTGRES_PASSWORD=password postgres
-
Create a database for
dstack.psql -h localhost -U postgres --command "CREATE DATABASE dstack" -
Run
dstack serveronce to create the previous database schema.DSTACK_DATABASE_URL=postgresql+asyncpg://postgres:password@localhost:5432/dstack dstack server
-
Generate the migration.
cd src/dstack/_internal/server/ DSTACK_DATABASE_URL=postgresql+asyncpg://postgres:password@localhost:5432/dstack alembic revision -m "<some message>" --autogenerate