mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-31 10:47:18 +00:00 
			
		
		
		
	Merge "queue_log: Add alembic script for generate db table for queue_log"
This commit is contained in:
		| @@ -11,6 +11,7 @@ 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_STOARGE` of voicemail messages | ||||
|  | ||||
| Alembic uses SQLAlchemy, which has support for | ||||
|   | ||||
							
								
								
									
										58
									
								
								contrib/ast-db-manage/queue_log.ini.sample
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								contrib/ast-db-manage/queue_log.ini.sample
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,58 @@ | ||||
| # A generic, single database configuration. | ||||
|  | ||||
| [alembic] | ||||
| # path to migration scripts | ||||
| script_location = queue_log | ||||
|  | ||||
| # template used to generate migration files | ||||
| # file_template = %%(rev)s_%%(slug)s | ||||
|  | ||||
| # max length of characters to apply to the | ||||
| # "slug" field | ||||
| #truncate_slug_length = 40 | ||||
|  | ||||
| # set to 'true' to run the environment during | ||||
| # the 'revision' command, regardless of autogenerate | ||||
| # revision_environment = false | ||||
|  | ||||
| #sqlalchemy.url = driver://user:pass@localhost/dbname | ||||
|  | ||||
|  | ||||
| #sqlalchemy.url = mysql://user:pass@localhost/queue_log | ||||
| sqlalchemy.url = postgresql://user:pass@localhost/queue_log | ||||
|  | ||||
|  | ||||
| # Logging configuration | ||||
| [loggers] | ||||
| keys = root,sqlalchemy,alembic | ||||
|  | ||||
| [handlers] | ||||
| keys = console | ||||
|  | ||||
| [formatters] | ||||
| keys = generic | ||||
|  | ||||
| [logger_root] | ||||
| level = WARN | ||||
| handlers = console | ||||
| qualname = | ||||
|  | ||||
| [logger_sqlalchemy] | ||||
| level = WARN | ||||
| handlers = | ||||
| qualname = sqlalchemy.engine | ||||
|  | ||||
| [logger_alembic] | ||||
| level = INFO | ||||
| handlers = | ||||
| qualname = alembic | ||||
|  | ||||
| [handler_console] | ||||
| class = StreamHandler | ||||
| args = (sys.stderr,) | ||||
| level = NOTSET | ||||
| formatter = generic | ||||
|  | ||||
| [formatter_generic] | ||||
| format = %(levelname)-5.5s [%(name)s] %(message)s | ||||
| datefmt = %H:%M:%S | ||||
							
								
								
									
										1
									
								
								contrib/ast-db-manage/queue_log/env.py
									
									
									
									
									
										Symbolic link
									
								
							
							
						
						
									
										1
									
								
								contrib/ast-db-manage/queue_log/env.py
									
									
									
									
									
										Symbolic link
									
								
							| @@ -0,0 +1 @@ | ||||
| ../env.py | ||||
							
								
								
									
										24
									
								
								contrib/ast-db-manage/queue_log/script.py.mako
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								contrib/ast-db-manage/queue_log/script.py.mako
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,24 @@ | ||||
| """${message} | ||||
|  | ||||
| Revision ID: ${up_revision} | ||||
| Revises: ${down_revision | comma,n} | ||||
| Create Date: ${create_date} | ||||
|  | ||||
| """ | ||||
|  | ||||
| # revision identifiers, used by Alembic. | ||||
| revision = ${repr(up_revision)} | ||||
| down_revision = ${repr(down_revision)} | ||||
| branch_labels = ${repr(branch_labels)} | ||||
| depends_on = ${repr(depends_on)} | ||||
|  | ||||
| from alembic import op | ||||
| import sqlalchemy as sa | ||||
| ${imports if imports else ""} | ||||
|  | ||||
| def upgrade(): | ||||
|     ${upgrades if upgrades else "pass"} | ||||
|  | ||||
|  | ||||
| def downgrade(): | ||||
|     ${downgrades if downgrades else "pass"} | ||||
| @@ -0,0 +1,38 @@ | ||||
| """create queue_log table | ||||
|  | ||||
| Revision ID: 4105ee839f58 | ||||
| Revises: | ||||
| Create Date: 2016-09-30 22:32:45.918340 | ||||
|  | ||||
| """ | ||||
|  | ||||
| # revision identifiers, used by Alembic. | ||||
| revision = '4105ee839f58' | ||||
| down_revision = None | ||||
| branch_labels = None | ||||
| depends_on = None | ||||
|  | ||||
| from alembic import op | ||||
| import sqlalchemy as sa | ||||
|  | ||||
|  | ||||
| def upgrade(): | ||||
|     op.create_table( | ||||
|         'queue_log', | ||||
|         sa.Column('id', sa.BigInteger, primary_key=True, nullable=False, | ||||
|                   unique=True, autoincrement=True), | ||||
|         sa.Column('time', sa.DateTime()), | ||||
|         sa.Column('callid', sa.String(80)), | ||||
|         sa.Column('queuename', sa.String(256)), | ||||
|         sa.Column('agent', sa.String(80)), | ||||
|         sa.Column('event', sa.String(32)), | ||||
|         sa.Column('data1', sa.String(100)), | ||||
|         sa.Column('data2', sa.String(100)), | ||||
|         sa.Column('data3', sa.String(100)), | ||||
|         sa.Column('data4', sa.String(100)), | ||||
|         sa.Column('data5', sa.String(100)) | ||||
|     ) | ||||
|  | ||||
|  | ||||
| def downgrade(): | ||||
|     op.drop_table('queue_log') | ||||
		Reference in New Issue
	
	Block a user