Sean Bright 73836c7d97 res_pjsip_pubsub: Persist subscription 'generator_data' in sorcery 4 gün önce
..
cdr fd0ca1c3f9 Remove as much trailing whitespace as possible. 6 yıl önce
config 73836c7d97 res_pjsip_pubsub: Persist subscription 'generator_data' in sorcery 2 gün önce
queue_log b2c75ea7f3 ast-db-manage: Synchronize revisions between comments and code. 1 yıl önce
voicemail 0668e5494a app_voicemail_odbc: remove macrocontext from voicemail_messages table 8 ay önce
.gitignore 07e378e2c0 alembic: Update list of TLS methods available on ps_transports. 10 ay önce
README.md 815e99d5ea contrib: Spelling fixes 2 yıl önce
cdr.ini.sample a6612e80aa alembic: Adjust sippeers, queue_members, and voicemail_messages tables. 10 yıl önce
config.ini.sample a6612e80aa alembic: Adjust sippeers, queue_members, and voicemail_messages tables. 10 yıl önce
env.py 63168983aa alembic: Fix compatibility with SQLAlchemy 2.0+. 6 ay önce
queue_log.ini.sample 48161dfc71 queue_log: Add alembic script for generate db table for queue_log 4 yıl önce
voicemail.ini.sample a6612e80aa alembic: Adjust sippeers, queue_members, and voicemail_messages tables. 10 yıl önce

README.md

Asterisk Database Manager

Asterisk includes optional database integration for a variety of features. The purpose of this effort is to assist in managing the database schema for Asterisk database integration.

This is implemented as a set of repositories that contain database schema migrations, using Alembic. The existing repositories include:

  • cdr - Table used for Asterisk to store CDR records
  • config - Tables used for Asterisk realtime configuration
  • queue_log - Table used for Asterisk to store Queue Log records
  • voicemail - Tables used for ODBC_STORAGE of voicemail messages

Alembic uses SQLAlchemy, which has support for many databases.

IMPORTANT NOTE: This is brand new and the initial migrations are still subject to change. Only use this for testing purposes for now.

Example Usage

First, create an ini file that contains database connection details. For help with connection string details, see the SQLAlchemy docs.

$ cp config.ini.sample config.ini
... edit config.ini and change sqlalchemy.url ...

Next, bring the database up to date with the current schema.

$ alembic -c config.ini upgrade head

In the future, as additional database migrations are added, you can run alembic again to migrate the existing tables to the latest schema.

$ alembic -c config.ini upgrade head

The migrations support both upgrading and downgrading. You could go all the way back to where you started with no tables by downgrading back to the base revision.

$ alembic -c config.ini downgrade base

base and head are special revisions. You can refer to specific revisions to upgrade or downgrade to, as well.

$ alembic -c config.ini upgrade 4da0c5f79a9c

Offline Mode

If you would like to just generate the SQL statements that would have been executed, you can use alembic's offline mode.

$ alembic -c config.ini upgrade head --sql

Adding Database Migrations

The best way to learn about how to add additional database migrations is to refer to the Alembic documentation.