@@ -200,18 +200,94 @@ You can check all available options through the command:
200200
201201
202202 Database Migrations
203- ==========
203+ ==================
204+
204205Migrations are managed through `Alembic <https://alembic.sqlalchemy.org/en/latest/ >`_.
205- They are automatically run when starting DashAI. However, if you want to
206- run them manually, you can do it through the command (inside the `DashAI/ ` folder):
207- .. code :: bash
206+
207+ They are automatically executed when starting DashAI. However, if you want to
208+ run them manually, you can do so using the following command (inside the
209+ `DashAI/ ` folder):
210+
211+ .. code-block :: bash
212+
208213 $ alembic upgrade head
209214
210- To create a new migration after modifying the database models, run:
211- .. code :: bash
215+ This command applies all pending migrations up to the latest revision.
216+
217+ ---
218+
219+ Creating a New Migration
220+ ------------------------
221+
222+ After modifying the database models, a new migration can be generated using:
223+
224+ .. code-block :: bash
225+
212226 $ alembic revision --autogenerate -m " <<Your message here>>"
213- Where <<Your message here>> is a very brief description of the changes made.
214- Migrations are located in `alembic/versions `. Should be committed to the repository.
227+
228+ Where ``<<Your message here>> `` is a brief description of the changes introduced
229+ (e.g., *add model metadata table *, *update dataset schema *).
230+
231+ Generated migrations are located in the ``alembic/versions `` directory and
232+ **must be committed to the repository **.
233+
234+ It is strongly recommended to review the autogenerated migration file before
235+ applying it, as Alembic may not always detect complex changes correctly.
236+
237+ ---
238+
239+ Applying Migrations
240+ -------------------
241+
242+ To apply all pending migrations:
243+
244+ .. code-block :: bash
245+
246+ $ alembic upgrade head
247+
248+ To upgrade to a specific revision:
249+
250+ .. code-block :: bash
251+
252+ $ alembic upgrade < revision_id>
253+
254+ ---
255+
256+ Downgrading Migrations
257+ ----------------------
258+
259+ If you need to revert database changes, migrations can be downgraded using:
260+
261+ .. code-block :: bash
262+
263+ $ alembic downgrade -1
264+
265+ This command reverts the last applied migration.
266+
267+ To downgrade to a specific revision:
268+
269+ .. code-block :: bash
270+
271+ $ alembic downgrade < revision_id>
272+
273+ ---
274+
275+ Checking Migration Status
276+ -------------------------
277+
278+ To view the current migration applied to the database:
279+
280+ .. code-block :: bash
281+
282+ $ alembic current
283+
284+ To list the full migration history:
285+
286+ .. code-block :: bash
287+
288+ $ alembic history
289+
290+ ---
215291
216292
217293Testing
0 commit comments