Skip to content

Latest commit

 

History

History
42 lines (29 loc) · 1.15 KB

File metadata and controls

42 lines (29 loc) · 1.15 KB

Database migrations

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>" --autogenerate

Then adjust the generated migration if needed.

PostgreSQL enums

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.

  1. Run PostgreSQL.

    docker run --rm -p 5432:5432 -e POSTGRES_PASSWORD=password postgres
  2. Create a database for dstack.

    psql -h localhost -U postgres --command "CREATE DATABASE dstack"
  3. Run dstack server once to create the previous database schema.

    DSTACK_DATABASE_URL=postgresql+asyncpg://postgres:password@localhost:5432/dstack dstack server
  4. Generate the migration.

    cd src/dstack/_internal/server/
    DSTACK_DATABASE_URL=postgresql+asyncpg://postgres:password@localhost:5432/dstack alembic revision -m "<some message>" --autogenerate