xivo-manage-db
==============

Database can be changed three ways:

1. Changing schema/table specification
1. Populating data in database
1. Adding a migration script

See [private database wiki page](https://gitlab.com/avencall/randd-doc/wikis/coding/database)

Changing schema/table specification
-----------------------------------

If you need to change the database schema you must do it in two places:
- edit object in xivo-dao (for new installation)
- add a migration script in xivo-manage-db - see §Adding a migration script (for migration)


Populating data in database
---------------------------

Edit `populate/populate.sql` file which contains init data.


Adding a migration script
-------------------------

See [private database wiki page](https://gitlab.com/avencall/randd-doc/wikis/coding/database)

The `down_revision` ID must point to the last merged migration script.

Scripts should use alembic and/or sqlalchemy though migration scripts can be written in plain SQL commands with the .execute method.

Running unit tests
------------------

```
ci-tox
```
