Combine/cleanup alembic revisions

This commit is contained in:
Adrian Moennich 2017-06-30 16:14:17 +02:00
parent a502860849
commit 01ac6332b1
15 changed files with 106 additions and 550 deletions

View File

@ -1,48 +0,0 @@
"""Apply naming convention
Revision ID: 35badbd96474
Revises: 1bd6c5129d29
Create Date: 2015-03-10 11:31:42.850496
"""
from alembic import op
from indico.core.db.sqlalchemy.util.bulk_rename import bulk_rename
# revision identifiers, used by Alembic.
revision = '35badbd96474'
down_revision = '1bd6c5129d29'
mapping = {
'plugin_chat.chatroom_events': {
'indexes': {
'chatroom_events_pkey': 'pk_chatroom_events',
'ix_plugin_chat_chatroom_events_chatroom_id': 'ix_chatroom_events_chatroom_id',
'ix_plugin_chat_chatroom_events_event_id': 'ix_chatroom_events_event_id',
},
'constraints': {
'chatroom_events_chatroom_id_fkey': 'fk_chatroom_events_chatroom_id_chatrooms',
}
},
'plugin_chat.chatrooms': {
'indexes': {
'chatrooms_pkey': 'pk_chatrooms',
'ix_plugin_chat_chatrooms_created_by_id': 'ix_chatrooms_created_by_id',
},
'constraints': {
'chatrooms_jid_node_custom_server_key': 'uq_chatrooms_jid_node_custom_server',
}
}
}
def upgrade():
for stmt in bulk_rename(mapping):
op.execute(stmt)
def downgrade():
for stmt in bulk_rename(mapping, True):
op.execute(stmt)

View File

@ -1,24 +0,0 @@
"""Use FK for created_by_id
Revision ID: 16874c3e98a8
Revises: 35badbd96474
Create Date: 2015-05-08 14:45:51.811224
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = '16874c3e98a8'
down_revision = '35badbd96474'
def upgrade():
op.create_foreign_key(None,
'chatrooms', 'users',
['created_by_id'], ['id'],
source_schema='plugin_chat', referent_schema='users')
def downgrade():
op.drop_constraint('fk_chatrooms_created_by_id_users', 'chatrooms', schema='plugin_chat')

View File

@ -1,30 +0,0 @@
"""Use ACL settings
Revision ID: 30d94f9c21fc
Revises: 16874c3e98a8
Create Date: 2015-05-13 14:39:18.659784
"""
from alembic import context
from indico.core.db.sqlalchemy.util.convert_acl_settings import json_to_acl, acl_to_json
# revision identifiers, used by Alembic.
revision = '30d94f9c21fc'
down_revision = '16874c3e98a8'
acl_settings = {'plugin_chat.admins'}
def upgrade():
if context.is_offline_mode():
raise Exception('This upgrade is only possible in online mode')
json_to_acl(acl_settings)
def downgrade():
if context.is_offline_mode():
raise Exception('This downgrade is only possible in online mode')
acl_to_json(acl_settings)

View File

@ -1,27 +0,0 @@
"""Use proper FK for event_id
Revision ID: 685f2016cd0
Revises: 30d94f9c21fc
Create Date: 2015-09-24 12:01:59.704121
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = '685f2016cd0'
down_revision = '30d94f9c21fc'
def upgrade():
# delete orphaned payment chatroom associations
op.execute("DELETE FROM plugin_chat.chatroom_events ce WHERE NOT EXISTS "
"(SELECT 1 FROM events.events e WHERE e.id = ce.event_id)")
op.create_foreign_key(None,
'chatroom_events', 'events',
['event_id'], ['id'],
source_schema='plugin_chat', referent_schema='events')
def downgrade():
op.drop_constraint('fk_chatroom_events_event_id_events', 'chatroom_events', schema='plugin_chat')

View File

@ -1,20 +1,22 @@
"""Create tables
Revision ID: 1bd6c5129d29
Revises: None
Create Date: 2014-09-29 15:24:03.369025
Revision ID: 3888761f35f7
Revises:
Create Date: 2017-06-30 15:51:54.477207
"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.sql.ddl import CreateSchema, DropSchema
from indico.core.db.sqlalchemy import UTCDateTime
from sqlalchemy.sql.ddl import CreateSchema, DropSchema
# revision identifiers, used by Alembic.
revision = '1bd6c5129d29'
revision = '3888761f35f7'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
@ -26,23 +28,21 @@ def upgrade():
sa.Column('description', sa.Text(), nullable=False),
sa.Column('password', sa.String(), nullable=False),
sa.Column('custom_server', sa.String(), nullable=False),
sa.Column('created_by_id', sa.Integer(), nullable=False),
sa.Column('created_dt', UTCDateTime(), nullable=False),
sa.Column('modified_dt', UTCDateTime(), nullable=True),
sa.PrimaryKeyConstraint('id', name='chatrooms_pkey'),
sa.UniqueConstraint('jid_node', 'custom_server', name='chatrooms_jid_node_custom_server_key'),
sa.Index('ix_plugin_chat_chatrooms_created_by_id', 'created_by_id'),
sa.Column('created_by_id', sa.Integer(), nullable=False, index=True),
sa.Column('created_dt', UTCDateTime, nullable=False),
sa.Column('modified_dt', UTCDateTime, nullable=True),
sa.ForeignKeyConstraint(['created_by_id'], ['users.users.id']),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('jid_node', 'custom_server'),
schema='plugin_chat')
op.create_table('chatroom_events',
sa.Column('event_id', sa.Integer(), nullable=False, autoincrement=False),
sa.Column('chatroom_id', sa.Integer(), nullable=False),
sa.Column('event_id', sa.Integer(), autoincrement=False, nullable=False, index=True),
sa.Column('chatroom_id', sa.Integer(), autoincrement=False, nullable=False, index=True),
sa.Column('hidden', sa.Boolean(), nullable=False),
sa.Column('show_password', sa.Boolean(), nullable=False),
sa.ForeignKeyConstraint(['chatroom_id'], ['plugin_chat.chatrooms.id'],
name='chatroom_events_chatroom_id_fkey'),
sa.PrimaryKeyConstraint('event_id', 'chatroom_id', name='chatroom_events_pkey'),
sa.Index('ix_plugin_chat_chatroom_events_event_id', 'event_id'),
sa.Index('ix_plugin_chat_chatroom_events_chatroom_id', 'chatroom_id'),
sa.ForeignKeyConstraint(['chatroom_id'], ['plugin_chat.chatrooms.id']),
sa.ForeignKeyConstraint(['event_id'], ['events.events.id']),
sa.PrimaryKeyConstraint('event_id', 'chatroom_id'),
schema='plugin_chat')

View File

@ -1,57 +0,0 @@
"""Create tables
Revision ID: 1c2b0e17447d
Revises: None
Create Date: 2014-10-31 12:23:21.956730
"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
from sqlalchemy.sql.ddl import CreateSchema, DropSchema
from indico.core.db.sqlalchemy import UTCDateTime, PyIntEnum
from indico.core.db.sqlalchemy.util.bulk_rename import _rename_constraint
from indico_livesync.models.queue import ChangeType
# revision identifiers, used by Alembic.
revision = '1c2b0e17447d'
down_revision = None
def upgrade():
op.execute(CreateSchema('plugin_livesync'))
op.create_table('agents',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('backend_name', sa.String(), nullable=False),
sa.Column('name', sa.String(), nullable=False),
sa.Column('initial_data_exported', sa.Boolean(), nullable=False),
sa.Column('last_run', UTCDateTime(), nullable=False),
sa.Column('settings', postgresql.JSON(), nullable=False),
sa.PrimaryKeyConstraint('id', name='agents_pkey'),
schema='plugin_livesync')
op.create_table('queues',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('agent_id', sa.Integer(), nullable=False),
sa.Column('timestamp', UTCDateTime(), nullable=False),
sa.Column('processed', sa.Boolean(), nullable=False),
sa.Column('change', PyIntEnum(ChangeType), nullable=False),
sa.Column('type', sa.String(), nullable=False),
sa.Column('category_id', sa.String()),
sa.Column('event_id', sa.String()),
sa.Column('contrib_id', sa.String()),
sa.Column('subcontrib_id', sa.String()),
sa.ForeignKeyConstraint(['agent_id'], ['plugin_livesync.agents.id'], name='queues_agent_id_fkey'),
sa.PrimaryKeyConstraint('id', name='queues_pkey'),
sa.Index('ix_plugin_livesync_queues_agent_id', 'agent_id'),
schema='plugin_livesync')
# later migrations expect the old name...
op.execute(_rename_constraint('plugin_livesync', 'queues', 'ck_queues_valid_enum_change', 'queues_change_check'))
def downgrade():
op.drop_table('queues', schema='plugin_livesync')
op.drop_table('agents', schema='plugin_livesync')
op.execute(DropSchema('plugin_livesync'))

View File

@ -1,44 +0,0 @@
"""Apply naming convention
Revision ID: 5a9176bca07d
Revises: 1c2b0e17447d
Create Date: 2015-03-10 13:51:26.353667
"""
from alembic import op
from indico.core.db.sqlalchemy.util.bulk_rename import bulk_rename
# revision identifiers, used by Alembic.
revision = '5a9176bca07d'
down_revision = '1c2b0e17447d'
mapping = {
'plugin_livesync.agents': {
'indexes': {
'agents_pkey': 'pk_agents',
}
},
'plugin_livesync.queues': {
'indexes': {
'queues_pkey': 'pk_queues',
'ix_plugin_livesync_queues_agent_id': 'ix_queues_agent_id',
},
'constraints': {
'queues_change_check': 'ck_queues_valid_enum_change',
'queues_agent_id_fkey': 'fk_queues_agent_id_agents',
}
},
}
def upgrade():
for stmt in bulk_rename(mapping):
op.execute(stmt)
def downgrade():
for stmt in bulk_rename(mapping, True):
op.execute(stmt)

View File

@ -1,87 +0,0 @@
"""Reference the new objects
Revision ID: 2c9618a7a2ea
Revises: 5a9176bca07d
Create Date: 2016-04-08 11:37:44.632046
"""
import sqlalchemy as sa
from alembic import op
from indico.core.db.sqlalchemy import PyIntEnum
from indico_livesync.models.queue import EntryType
# revision identifiers, used by Alembic.
revision = '2c9618a7a2ea'
down_revision = '5a9176bca07d'
def upgrade():
op.drop_column('queues', 'type', schema='plugin_livesync')
op.drop_column('queues', 'category_id', schema='plugin_livesync')
op.drop_column('queues', 'event_id', schema='plugin_livesync')
op.drop_column('queues', 'contrib_id', schema='plugin_livesync')
op.drop_column('queues', 'subcontrib_id', schema='plugin_livesync')
op.add_column('queues', sa.Column('category_id', sa.Integer(), nullable=True), schema='plugin_livesync')
op.add_column('queues', sa.Column('event_id', sa.Integer(), nullable=True), schema='plugin_livesync')
op.add_column('queues', sa.Column('contribution_id', sa.Integer(), nullable=True), schema='plugin_livesync')
op.add_column('queues', sa.Column('subcontribution_id', sa.Integer(), nullable=True), schema='plugin_livesync')
op.add_column('queues', sa.Column('type', PyIntEnum(EntryType), nullable=False), schema='plugin_livesync')
op.create_index(None, 'queues', ['category_id'], schema='plugin_livesync')
op.create_index(None, 'queues', ['event_id'], schema='plugin_livesync')
op.create_index(None, 'queues', ['contribution_id'], schema='plugin_livesync')
op.create_index(None, 'queues', ['subcontribution_id'], schema='plugin_livesync')
op.create_foreign_key(None,
'queues', 'events',
['event_id'], ['id'],
source_schema='plugin_livesync', referent_schema='events')
op.create_foreign_key(None,
'queues', 'contributions',
['contribution_id'], ['id'],
source_schema='plugin_livesync', referent_schema='events')
op.create_foreign_key(None,
'queues', 'subcontributions',
['subcontribution_id'], ['id'],
source_schema='plugin_livesync', referent_schema='events')
op.create_check_constraint('valid_category_entry', 'queues',
'type != 1 OR (contribution_id IS NULL AND event_id IS NULL AND '
'subcontribution_id IS NULL AND category_id IS NOT NULL)',
schema='plugin_livesync')
op.create_check_constraint('valid_event_entry', 'queues',
'type != 2 OR (category_id IS NULL AND contribution_id IS NULL AND '
'subcontribution_id IS NULL AND event_id IS NOT NULL)',
schema='plugin_livesync')
op.create_check_constraint('valid_contribution_entry', 'queues',
'type != 3 OR (category_id IS NULL AND event_id IS NULL AND '
'subcontribution_id IS NULL AND contribution_id IS NOT NULL)',
schema='plugin_livesync')
op.create_check_constraint('valid_subcontribution_entry', 'queues',
'type != 4 OR (category_id IS NULL AND contribution_id IS NULL AND '
'event_id IS NULL AND subcontribution_id IS NOT NULL)',
schema='plugin_livesync')
op.drop_constraint('ck_queues_valid_enum_change', 'queues', schema='plugin_livesync')
op.create_check_constraint('valid_enum_change', 'queues',
'change IN (1, 2, 3, 4, 5)',
schema='plugin_livesync')
def downgrade():
op.drop_constraint('ck_queues_valid_enum_change', 'queues', schema='plugin_livesync')
op.create_check_constraint('valid_enum_change', 'queues',
'change IN (1, 2, 3, 4, 5, 6)',
schema='plugin_livesync')
op.drop_constraint('ck_queues_valid_category_entry', 'queues', schema='plugin_livesync')
op.drop_constraint('ck_queues_valid_event_entry', 'queues', schema='plugin_livesync')
op.drop_constraint('ck_queues_valid_contribution_entry', 'queues', schema='plugin_livesync')
op.drop_constraint('ck_queues_valid_subcontribution_entry', 'queues', schema='plugin_livesync')
op.drop_column('queues', 'type', schema='plugin_livesync')
op.drop_column('queues', 'category_id', schema='plugin_livesync')
op.drop_column('queues', 'event_id', schema='plugin_livesync')
op.drop_column('queues', 'subcontribution_id', schema='plugin_livesync')
op.drop_column('queues', 'contribution_id', schema='plugin_livesync')
op.add_column('queues', sa.Column('type', sa.String(), nullable=False), schema='plugin_livesync')
op.add_column('queues', sa.Column('category_id', sa.String(), nullable=True), schema='plugin_livesync')
op.add_column('queues', sa.Column('event_id', sa.String(), nullable=True), schema='plugin_livesync')
op.add_column('queues', sa.Column('contrib_id', sa.String(), nullable=True), schema='plugin_livesync')
op.add_column('queues', sa.Column('subcontrib_id', sa.String(), nullable=True), schema='plugin_livesync')

View File

@ -1,23 +0,0 @@
"""Use foreign key for categories
Revision ID: 230c086da074
Revises: 2c9618a7a2ea
Create Date: 2016-07-13 15:57:49.911262
"""
from alembic import op
revision = '230c086da074'
down_revision = '2c9618a7a2ea'
def upgrade():
op.create_foreign_key(None,
'queues', 'categories',
['category_id'], ['id'],
source_schema='plugin_livesync', referent_schema='categories')
def downgrade():
op.drop_constraint('fk_queues_category_id_categories', 'queues', schema='plugin_livesync')

View File

@ -1,84 +0,0 @@
"""Add session to LiveSyncQueueEntry
Revision ID: 205f944640f6
Revises: 230c086da074
Create Date: 2016-07-15 17:36:12.702497
"""
import sqlalchemy as sa
from alembic import op
revision = '205f944640f6'
down_revision = '230c086da074'
def upgrade():
op.add_column('queues', sa.Column('session_id', sa.Integer(), nullable=True), schema='plugin_livesync')
op.create_foreign_key(None,
'queues', 'sessions',
['session_id'], ['id'],
source_schema='plugin_livesync', referent_schema='events')
op.create_index(None, 'queues', ['session_id'], unique=False, schema='plugin_livesync')
op.drop_constraint('ck_queues_valid_enum_type', 'queues', schema='plugin_livesync')
op.drop_constraint('ck_queues_valid_category_entry', 'queues', schema='plugin_livesync')
op.drop_constraint('ck_queues_valid_event_entry', 'queues', schema='plugin_livesync')
op.drop_constraint('ck_queues_valid_contribution_entry', 'queues', schema='plugin_livesync')
op.drop_constraint('ck_queues_valid_subcontribution_entry', 'queues', schema='plugin_livesync')
op.create_check_constraint('valid_enum_type', 'queues',
'type IN (1, 2, 3, 4, 5)',
schema='plugin_livesync')
op.create_check_constraint('valid_category_entry', 'queues',
'type != 1 OR (contribution_id IS NULL AND event_id IS NULL AND session_id IS NULL AND '
'subcontribution_id IS NULL AND category_id IS NOT NULL)',
schema='plugin_livesync')
op.create_check_constraint('valid_event_entry', 'queues',
'type != 2 OR (category_id IS NULL AND contribution_id IS NULL AND session_id IS NULL '
'AND subcontribution_id IS NULL AND event_id IS NOT NULL)',
schema='plugin_livesync')
op.create_check_constraint('valid_session_entry', 'queues',
'type != 5 OR (category_id IS NULL AND contribution_id IS NULL AND event_id IS NULL '
'AND subcontribution_id IS NULL AND session_id IS NOT NULL)',
schema='plugin_livesync')
op.create_check_constraint('valid_contribution_entry', 'queues',
'type != 3 OR (category_id IS NULL AND event_id IS NULL AND session_id IS NULL AND '
'subcontribution_id IS NULL AND contribution_id IS NOT NULL)',
schema='plugin_livesync')
op.create_check_constraint('valid_subcontribution_entry', 'queues',
'type != 4 OR (category_id IS NULL AND contribution_id IS NULL AND event_id IS NULL AND '
'session_id IS NULL AND subcontribution_id IS NOT NULL)',
schema='plugin_livesync')
def downgrade():
op.drop_constraint('ck_queues_valid_category_entry', 'queues', schema='plugin_livesync')
op.drop_constraint('ck_queues_valid_event_entry', 'queues', schema='plugin_livesync')
op.drop_constraint('ck_queues_valid_session_entry', 'queues', schema='plugin_livesync')
op.drop_constraint('ck_queues_valid_contribution_entry', 'queues', schema='plugin_livesync')
op.drop_constraint('ck_queues_valid_subcontribution_entry', 'queues', schema='plugin_livesync')
op.drop_column('queues', 'session_id', schema='plugin_livesync')
op.create_check_constraint('valid_category_entry', 'queues',
'type != 1 OR (contribution_id IS NULL AND event_id IS NULL AND '
'subcontribution_id IS NULL AND category_id IS NOT NULL)',
schema='plugin_livesync')
op.create_check_constraint('valid_event_entry', 'queues',
'type != 2 OR (category_id IS NULL AND contribution_id IS NULL AND '
'subcontribution_id IS NULL AND event_id IS NOT NULL)',
schema='plugin_livesync')
op.create_check_constraint('valid_contribution_entry', 'queues',
'type != 3 OR (category_id IS NULL AND event_id IS NULL AND '
'subcontribution_id IS NULL AND contribution_id IS NOT NULL)',
schema='plugin_livesync')
op.create_check_constraint('valid_subcontribution_entry', 'queues',
'type != 4 OR (category_id IS NULL AND contribution_id IS NULL AND '
'event_id IS NULL AND subcontribution_id IS NOT NULL)',
schema='plugin_livesync')
op.drop_constraint('ck_queues_valid_enum_type', 'queues', schema='plugin_livesync')
op.create_check_constraint('valid_enum_type', 'queues',
'type IN (1, 2, 3, 4)',
schema='plugin_livesync')

View File

@ -0,0 +1,75 @@
"""Create tables
Revision ID: aa0dbc6c14aa
Revises:
Create Date: 2017-06-30 15:57:09.132083
"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
from sqlalchemy.sql.ddl import CreateSchema, DropSchema
from indico.core.db.sqlalchemy import PyIntEnum, UTCDateTime
from indico_livesync.models.queue import ChangeType, EntryType
# revision identifiers, used by Alembic.
revision = 'aa0dbc6c14aa'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
op.execute(CreateSchema('plugin_livesync'))
op.create_table('agents',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('backend_name', sa.String(), nullable=False),
sa.Column('name', sa.String(), nullable=False),
sa.Column('initial_data_exported', sa.Boolean(), nullable=False),
sa.Column('last_run', UTCDateTime, nullable=False),
sa.Column('settings', postgresql.JSON(astext_type=sa.Text()), nullable=False),
sa.PrimaryKeyConstraint('id'),
schema='plugin_livesync')
op.create_table('queues',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('agent_id', sa.Integer(), nullable=False, index=True),
sa.Column('timestamp', UTCDateTime, nullable=False),
sa.Column('processed', sa.Boolean(), nullable=False),
sa.Column('change', PyIntEnum(ChangeType), nullable=False),
sa.Column('type', PyIntEnum(EntryType), nullable=False),
sa.Column('category_id', sa.Integer(), nullable=True, index=True),
sa.Column('event_id', sa.Integer(), nullable=True, index=True),
sa.Column('contribution_id', sa.Integer(), nullable=True, index=True),
sa.Column('session_id', sa.Integer(), nullable=True, index=True),
sa.Column('subcontribution_id', sa.Integer(), nullable=True, index=True),
sa.CheckConstraint('type != 1 OR (contribution_id IS NULL AND event_id IS NULL AND session_id '
'IS NULL AND subcontribution_id IS NULL AND category_id IS NOT NULL)',
name='valid_category_entry'),
sa.CheckConstraint('type != 2 OR (category_id IS NULL AND contribution_id IS NULL AND session_id '
'IS NULL AND subcontribution_id IS NULL AND event_id IS NOT NULL)',
name='valid_event_entry'),
sa.CheckConstraint('type != 3 OR (category_id IS NULL AND event_id IS NULL AND session_id '
'IS NULL AND subcontribution_id IS NULL AND contribution_id IS NOT NULL)',
name='valid_contribution_entry'),
sa.CheckConstraint('type != 4 OR (category_id IS NULL AND contribution_id IS NULL AND event_id '
'IS NULL AND session_id IS NULL AND subcontribution_id IS NOT NULL)',
name='valid_subcontribution_entry'),
sa.CheckConstraint('type != 5 OR (category_id IS NULL AND contribution_id IS NULL AND event_id '
'IS NULL AND subcontribution_id IS NULL AND session_id IS NOT NULL)',
name='valid_session_entry'),
sa.ForeignKeyConstraint(['agent_id'], ['plugin_livesync.agents.id']),
sa.ForeignKeyConstraint(['category_id'], ['categories.categories.id']),
sa.ForeignKeyConstraint(['contribution_id'], ['events.contributions.id']),
sa.ForeignKeyConstraint(['event_id'], ['events.events.id']),
sa.ForeignKeyConstraint(['session_id'], ['events.sessions.id']),
sa.ForeignKeyConstraint(['subcontribution_id'], ['events.subcontributions.id']),
sa.PrimaryKeyConstraint('id', name=op.f('pk_queues')),
schema='plugin_livesync')
def downgrade():
op.drop_table('queues', schema='plugin_livesync')
op.drop_table('agents', schema='plugin_livesync')
op.execute(DropSchema('plugin_livesync'))

View File

@ -1,39 +0,0 @@
"""Apply naming convention
Revision ID: 3520616f8ff7
Revises: a702ad0bcea
Create Date: 2015-03-10 13:59:53.955083
"""
from alembic import op
from indico.core.db.sqlalchemy.util.bulk_rename import bulk_rename
# revision identifiers, used by Alembic.
revision = '3520616f8ff7'
down_revision = 'a702ad0bcea'
mapping = {
'plugin_vc_vidyo.vidyo_extensions': {
'indexes': {
'vidyo_extensions_pkey': 'pk_vidyo_extensions',
'ix_plugin_vc_vidyo_vidyo_extensions_extension': 'ix_vidyo_extensions_extension',
'ix_plugin_vc_vidyo_vidyo_extensions_owned_by_id': 'ix_vidyo_extensions_owned_by_id',
},
'constraints': {
'vidyo_extensions_vc_room_id_fkey': 'fk_vidyo_extensions_vc_room_id_vc_rooms',
}
}
}
def upgrade():
for stmt in bulk_rename(mapping):
op.execute(stmt)
def downgrade():
for stmt in bulk_rename(mapping, True):
op.execute(stmt)

View File

@ -1,26 +0,0 @@
"""Use FK for owned_by_id and make it NOT NULL
Revision ID: 3f376d68efc8
Revises: 3520616f8ff7
Create Date: 2015-05-08 19:34:25.491411
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = '3f376d68efc8'
down_revision = '3520616f8ff7'
def upgrade():
op.alter_column('vidyo_extensions', 'owned_by_id', nullable=False, schema='plugin_vc_vidyo')
op.create_foreign_key(None,
'vidyo_extensions', 'users',
['owned_by_id'], ['id'],
source_schema='plugin_vc_vidyo', referent_schema='users')
def downgrade():
op.drop_constraint('fk_vidyo_extensions_owned_by_id_users', 'vidyo_extensions', schema='plugin_vc_vidyo')
op.alter_column('vidyo_extensions', 'owned_by_id', nullable=True, schema='plugin_vc_vidyo')

View File

@ -1,30 +0,0 @@
"""Use ACL settings
Revision ID: 4ad9ccfb3d32
Revises: 3f376d68efc8
Create Date: 2015-05-13 14:22:09.748726
"""
from alembic import context
from indico.core.db.sqlalchemy.util.convert_acl_settings import json_to_acl, acl_to_json
# revision identifiers, used by Alembic.
revision = '4ad9ccfb3d32'
down_revision = '3f376d68efc8'
acl_settings = {'plugin_vc_vidyo.managers', 'plugin_vc_vidyo.acl'}
def upgrade():
if context.is_offline_mode():
raise Exception('This upgrade is only possible in online mode')
json_to_acl(acl_settings)
def downgrade():
if context.is_offline_mode():
raise Exception('This downgrade is only possible in online mode')
acl_to_json(acl_settings)

View File

@ -1,8 +1,8 @@
"""Create extensions table
"""Create tables
Revision ID: a702ad0bcea
Revises: None
Create Date: 2015-02-19 11:58:11.756966
Revision ID: 6019621fea50
Revises:
Create Date: 2017-06-30 16:11:31.486845
"""
import sqlalchemy as sa
@ -12,21 +12,21 @@ from sqlalchemy.sql.ddl import CreateSchema, DropSchema
# revision identifiers, used by Alembic.
revision = 'a702ad0bcea'
revision = '6019621fea50'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
op.execute(CreateSchema('plugin_vc_vidyo'))
op.create_table('vidyo_extensions',
sa.Column('vc_room_id', sa.Integer(), nullable=False),
sa.Column('extension', sa.BigInteger(), nullable=True),
sa.Column('owned_by_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['vc_room_id'], ['events.vc_rooms.id'],
name='vidyo_extensions_vc_room_id_fkey'),
sa.PrimaryKeyConstraint('vc_room_id', name='vidyo_extensions_pkey'),
sa.Index('ix_plugin_vc_vidyo_vidyo_extensions_extension', 'extension'),
sa.Index('ix_plugin_vc_vidyo_vidyo_extensions_owned_by_id', 'owned_by_id'),
sa.Column('extension', sa.BigInteger(), nullable=True, index=True),
sa.Column('owned_by_id', sa.Integer(), nullable=False, index=True),
sa.ForeignKeyConstraint(['owned_by_id'], ['users.users.id']),
sa.ForeignKeyConstraint(['vc_room_id'], ['events.vc_rooms.id']),
sa.PrimaryKeyConstraint('vc_room_id'),
schema='plugin_vc_vidyo')