Tools to manage the DBs (switch, save & restore)
All scripts are based on the idea that we are working on one DB at the time. To define and get that current DB's name, setdb
and getdb
must be used
setdb
will write the argument in a hidden file. It also writes the DB on the.odoorc
file (but this line is not mandatory and can be removed)getdb
simply reads and returns the content of the hidden file
Suppose an initialized DB with a specific configuration on it. I want to save its state and have the possibility to restore that state
savedb
will save the current DB (getdb
) into a new one. Suppose X is the name of the current DB:- If an argument Y is given to
savedb
: the saved DB is called X__Y - Otherwise: the saved DB is called X__SAVEPOINT
- If an argument Y is given to
restoredb
tries to find a saved state of the current DB (getdb
) and restores it. Suppose X is the name of the current DB:- If an argument Y is given to
restoredb
: the script tries to find a saved state of X called Y (i.e., it searches for a DB called X__Y). If such a state exists, it will restore it on X - Otherwise, it tries to find a saved state called SAVEPOINT and does the same than above
- If an argument Y is given to
/!\ The filestore is never saved nor restored. In most cases, it is not useful.
I want to work on a DB called 1234567-15.0:
setdb 1234567-15.0
I run Odoo, I create some products and set a specific configuration. I don't want to lose it:
savedb config
Then I do some stuff and I create a SO. I'm going to validate it but I would like to save the current state and I don't care about the name:
savedb
Again, I confirm the SO and do some stuff. Finally, I want to go back either before the SO creation or before its validation:
restoredb config
restoredb
-
copydb
takes two arguments X and Y and copies X on a new DB called Y. It is used bysavedb
andrestoredb
-
killodoo
kills all Odoo processes. It is executed bycopydb
-
ldb
lists all databases -
dropall
: for each argument X, it drops all databases that contain X in their name -
sdv <version>
: usessetdb
with the value of the current db (getdb
) and concatenated with'-<version>'
-
getticket
: extract the ticket number from the db's name -
branch <branch-s name>
->git checkout -b <version>-<#ticket>-<branch's name>-yosa
-
cv <version>
: change the value of theXenv
symbolic link and checks out version if in Odoo -
xenv
: prints out the current point value of the symbolic link -
changexenv <target>
: change the value of the symbolic link with the<target>
's value -
.bash_completion
allows the user to auto complete the arguments ofsetdb
,savedb
andrestoredb
in his terminal -
renamedb
: takes one argument X and will rename the current DB into X