app_queue: Add RealTime support for queue rules
[asterisk/asterisk.git] / contrib / ast-db-manage / README.md
1 Asterisk Database Manager
2 =========================
3
4 Asterisk includes optional database integration for a variety of features.
5 The purpose of this effort is to assist in managing the database schema
6 for Asterisk database integration.
7
8 This is implemented as a set of repositories that contain database schema
9 migrations, using [Alembic](http://alembic.readthedocs.org).  The existing
10 repositories include:
11
12  * `config` - Tables used for Asterisk realtime configuration
13  * `voicemail` - Tables used for `ODBC_STOARGE` of voicemail messages
14
15 Alembic uses SQLAlchemy, which has support for
16 [many databases](http://docs.sqlalchemy.org/en/rel_0_8/dialects/index.html).
17
18 IMPORTANT NOTE: This is brand new and the initial migrations are still subject
19 to change.  Only use this for testing purposes for now.
20
21 Example Usage
22 -------------
23
24 First, create an ini file that contains database connection details.  For help
25 with connection string details, see the
26 [SQLAlchemy docs](http://docs.sqlalchemy.org/en/rel_0_8/core/engines.html#database-urls).
27
28     $ cp config.ini.sample config.ini
29     ... edit config.ini and change sqlalchemy.url ...
30
31 Next, bring the database up to date with the current schema.
32
33     $ alembic -c config.ini upgrade head
34
35 In the future, as additional database migrations are added, you can run
36 alembic again to migrate the existing tables to the latest schema.
37
38     $ alembic -c config.ini upgrade head
39
40 The migrations support both upgrading and downgrading.  You could go all the
41 way back to where you started with no tables by downgrading back to the base
42 revision.
43
44     $ alembic -c config.ini downgrade base
45
46 `base` and `head` are special revisions.  You can refer to specific revisions
47 to upgrade or downgrade to, as well.
48
49     $ alembic -c config.ini upgrade 4da0c5f79a9c
50
51 Offline Mode
52 ------------
53
54 If you would like to just generate the SQL statements that would have been
55 executed, you can use alembic's offline mode.
56
57     $ alembic -c config.ini upgrade head --sql
58
59 Adding Database Migrations
60 --------------------------
61
62 The best way to learn about how to add additional database migrations is to
63 refer to the [Alembic documentation](http://alembic.readthedocs.org).