@@ -28,7 +28,7 @@ Before pushing to GitHub, run the following commands:
28
28
1 . Run the static type checker: ` make type-check `
29
29
1 . Build the documentation (see [ Sphinx tutorial] ( https://www.sphinx-doc.org/en/master/tutorial/ ) ): ` make docs-build `
30
30
31
- ### Instructions for database updating
31
+ ### Instructions for creating a new database version
32
32
33
33
The package ` cads-broker ` comes with its 'broker' database.
34
34
In case of database structure upgrade, developers must follow these steps:
@@ -46,6 +46,34 @@ In case of database structure upgrade, developers must follow these steps:
46
46
Similarly, do the same with the ` downgrade ` function.
47
47
1 . Commit and push the modifications and the new file.
48
48
49
+ ### Instructions for moving between different database versions
50
+
51
+ The package comes with its own 'broker-alembic-cli' script in order to move between different
52
+ database versions. This script is a slight modified version of the 'alembic' script, overriding
53
+ default config path used ([ /alembic.ini] ( /alembic.ini ) ) and the sqlalchemy.url used, that is
54
+ automatically computed by the environment and not read from any ini file.
55
+
56
+ All the database releases where you can migrate up and down must be defined by files contained inside
57
+ the folder [ /alembic/versions] ( /alembic/versions ) . All these files are in a version queue: each file has
58
+ link to its revision hash (variable 'revision', the prefix of the file name) and to the next older one
59
+ (variable 'down_revision'), and contains code to step up and down that database version.\
60
+ Some useful commands are listed below.
61
+
62
+ - To migrate to the newest version, type:\
63
+ ` broker-alembic-cli upgrade head `
64
+ - To upgrade to a specific version hash, for example 8ccbe515155c, type:\
65
+ ` broker-alembic-cli upgrade 8ccbe515155c `
66
+ - To downgrade to a specific version hash, for example 8ccbe515155c, type:\
67
+ ` broker-alembic-cli downgrade 8ccbe515155c `
68
+ - To get the current version hash of the database, type:\
69
+ ` broker-alembic-cli current `
70
+
71
+ Database migration changes could be applied to the cacholote component of the database, too. In such case,
72
+ migrate the cacholote component after the migration by the 'broker-alembic-cli' tool.
73
+
74
+ Other details are the same of the standard alembic migration tool,
75
+ see the [ Alembic tutorial] ( https://alembic.sqlalchemy.org/en/latest/tutorial.html ) .
76
+
49
77
For details about the alembic migration tool, see the [ Alembic tutorial] ( https://alembic.sqlalchemy.org/en/latest/tutorial.html ) .
50
78
51
79
## Quality of Service rules examples
0 commit comments