File tree Expand file tree Collapse file tree 1 file changed +30
-5
lines changed
libs/tracker/llmstudio_tracker/db/migrations Expand file tree Collapse file tree 1 file changed +30
-5
lines changed Original file line number Diff line number Diff line change 1- Generic single-database configuration.
1+ # How to use Alembic for DB Schema Migrations
22
3+ Schema migration without losing any data.
34
4- 1. Track model changes
5- Run `alembic revision --autogenerate`
5+ ## 1. Make your changes
66
7- 2. Apply schema
8- Run `alembic upgrade head`
7+ Make your changes to the models and schemas under `libs/tracker/llmstudio_tracking/db`.
8+
9+ ## 2. Setup
10+ Ensure Alembic is installed (included via llmstudio-tracker extra):
11+ ```
12+ poetry install --extras tracker
13+ ```
14+
15+ Make sure your environment variable LLMSTUDIO_TRACKING_URI is set correctly for the DB, `alembic.ini` will be using this.
16+
17+ ## 3. Creating Migrations
18+ Whenever you make changes to your SQLAlchemy models, generate a new migration:
19+ ```
20+ poetry run alembic revision --autogenerate -m "describe your change"
21+ ```
22+
23+ This will create a migration file in `libs/tracker/llmstudio_tracking/db/migrations/versions/`.
24+ Review the generated migration file and adjust if needed.
25+
26+
27+ ## 4. Applying Migrations
28+ Run all unapplied migrations:
29+ ```
30+ poetry run alembic upgrade head
31+ ```
32+
33+ You will now have a table on your DB with the applied migration id.
You can’t perform that action at this time.
0 commit comments