Package: anybox.pg.odoo
anybox.pg.odooThis tool basically manages versioned snapshots of the current database,
mimicking the common workflow of VCS tools such as init, commit, revert, log, etc.
It was first created to snapshot Odoo databases but may be easily modified to be
agnostic.Contentsanybox.pg.odooInstallUsageHow it works and polluteswhat’s next? (todo list)ContributeChangelog0.7 (unreleased)0.6 (2014-11-02)0.5 (2014-10-19)0.4 (2014-10-19)0.3 (2014-10-16)0.2 (2014-10-15 after sleeping)0.1 (2014-10-15)InstallThis tool works on Python 2.7 and Python 3.x.
Install as any normal Python distribution, in a virtualenv, buildout or
system-wide. The only current dependency ispsycopg2>= 2.5.Example with a virtualenv:$ virtualenv sandbox && source sandbox/bin/activate
$ pip install anybox.pg.odooUsageFirst read the available commands withodb-h.
You get the available commands:init                Set the current db
commit              Save the current db in a new revision
info                Display the revision of the current db
revert              Drop the current db and clone from a previous revision
log                 List all available revisions
purge               Destroy revisions
tags                List all tags
tag                 Tag a specific revisionYou should first set the current database withodb init:$ odb init demo8
Now revision 1Then you can get the current revision withodb info:$ odb info
database: demo8
revision : 1 (parent: 0)Commit the current database to create a snapshot and a new revision withodb commit:$ odb commit
Now revision 2
$ odb info
database: demo8
revision : 2 (parent: 1)
$ odb commit
Now revision 3
$ odb commit
Now revision 4You can revert back to the last revision of the database (the parent) withodb revert:$ odb revert
Reverted to parent 3, now at revision 4You can also revert back to any previous revision:$ odb revert 2
Reverted to parent 2, now at revision 4
$ odb info
database: demo8
revision : 4 (parent: 2)You can put tags on a revision, revert to a tag and delete a tag withodb tagandodb tags:$ odb tag v1 2
$ odb tag v2 3
$ odb tags
v2 (demo8*3)
v1 (demo8*2)
$ odb revert v1
Reverted to parent 2, now at revision 4
$ odb tag -d v1The you can display all the revisions withodb log:$ odb log
demo8:
    revision: 4
    parent: 2
demo8*3:
    revision: 3
    parent: 2
    tag: v2
demo8*2:
    revision: 2
    parent: 1
demo8*1:
    revision: 1
    parent: 0Then you can purge all the revisions except the tags:$ odb purge keeptagsor all the revisions:$ odb purge allHow it works and pollutesIt uses theCREATE DATABASE FROM TEMPLATEfeature of PostgreSQLIt currently stores version information in their_config_parametertable
of Odoo (though this will change in the future).It expects that the connection to PostgreSQL is done through Unix Domain
Socket with the current user being allowed to create and drop databases.It stores the current database in~/.anybox.pg.odoowhat’s next? (todo list)Use a dedicated database to store version information instead of their_config_parametertableImplement diff (#fear)Improve the database naming schemeContributeMercurial repository and bug tracker:https://bitbucket.org/anybox/anybox.pg.odooRun tests with:$ python setup.py testChangelog0.7 (unreleased)fixed setting autocommit before creating new transactionfixed error in Python 3implement graph optionodb log--graphfixedissue #7,
force to close exists connexion on copied database before make the copyImplementissue #4limitlog option to limit number of changes
displayed0.6 (2014-11-02)fixed error in Python 3remove tag and message of the current version after commit and revert0.5 (2014-10-19)Works on Python 3.1+Works on Postgres 9.1 and maybe lowerodb purge keeptags: purge all but tagsimplemented commit messagerevert now checks that the source db exists (much safer)0.4 (2014-10-19)Implementedodb logImplementedodb purgeImplementedodb tagand revert to tagImplementedodb tagsRenamed version to revisionRenamed snapshot() to commit()0.3 (2014-10-16)Keep the same db as the current one to work in placeFixed versionning and start at 1Also disconnect during revert operationRemoved the unneeded tip0.2 (2014-10-15 after sleeping)Fixed packagingFixed therevertbehaviourAllow to revert without argumentImproved doc0.1 (2014-10-15)Initial draft