def do_upgrade():
    """Implement your upgrades here."""
    # First upgrade bwlWORKFLOW for proper foreign key creation
    with op.batch_alter_table("bwlWORKFLOW", recreate="always", table_kwargs={"mysql_engine": 'InnoDB'}) as batch_op:
        pass

    with op.batch_alter_table("bwlOBJECT", recreate="always", table_kwargs={"mysql_engine": 'InnoDB'}) as batch_op:
        batch_op.create_index('ix_bwlOBJECT_version', ['version'])
        batch_op.create_index('ix_bwlOBJECT_data_type', ['data_type'])
        batch_op.create_foreign_key("bwlOBJECT_ibfk_1",
                                    "bwlWORKFLOW",
                                    ["id_workflow"],
                                    ["uuid"],
                                    ondelete="CASCADE")

    op.create_foreign_key("bwlOBJECT_ibfk_2",
                          "bwlOBJECT",
                          "bwlOBJECT",
                          ["id_parent"],
                          ["id"],
                          ondelete="CASCADE")

    with op.batch_alter_table("bwlWORKFLOWLOGGING", recreate="always", table_kwargs={"mysql_engine": 'InnoDB'}) as batch_op:
        batch_op.create_foreign_key("bwlWORKFLOWLOGGING_ibfk_1",
                                    "bwlWORKFLOW",
                                    ["id_object"],
                                    ["uuid"])

    with op.batch_alter_table("bwlOBJECTLOGGING", recreate="always", table_kwargs={"mysql_engine": 'InnoDB'}) as batch_op:
        batch_op.create_foreign_key("bwlOBJECTLOGGING_ibfk_1",
                                    "bwlOBJECT",
                                    ["id_object"],
                                    ["id"])
Exemplo n.º 2
0
def do_upgrade():
    """Implement your upgrades here."""
    with op.batch_alter_table("UserEXT") as batch_op:
        batch_op.alter_column(
            column_name='id',
            type_=db.String(255), nullable=False
        )
Exemplo n.º 3
0
def do_upgrade():
    """Implement your upgrades here."""
    with op.batch_alter_table("bwlWORKFLOWLOGGING") as batch_op:
        batch_op.alter_column(
            column_name='id_object',
            type_=db.String(36), nullable=False
        )
def do_upgrade():
    """Perfrom upgrade."""
    if op.has_table('usergroup'):
        op.rename_table(
            old_table_name='usergroup',
            new_table_name='group'
        )
        with op.batch_alter_table("group") as batch_op:
            batch_op.drop_index('ix_usergroup_name')
            batch_op.create_index('ix_group_name', ['name'], unique=True)
            batch_op.alter_column('name', server_default=None)
            batch_op.add_column(db.Column('is_managed', db.Boolean(),
                                nullable=False, default=False))
            batch_op.alter_column(
                column_name='join_policy',
                new_column_name='privacy_policy',
                type_=db.String(length=1), nullable=False
            )
            batch_op.drop_index('login_method_name')
            batch_op.alter_column(
                column_name='login_method',
                new_column_name='subscription_policy',
                type_=db.String(length=1), nullable=False,
                server_default=None
            )
            batch_op.add_column(db.Column('created', db.DateTime(),
                                nullable=False, default=datetime.now))
            batch_op.add_column(db.Column('modified', db.DateTime(),
                                nullable=False, default=datetime.now,
                                onupdate=datetime.now))
    else:
        op.create_table(
            'group',
            db.Column('id', db.Integer(15, unsigned=True), nullable=False,
                      autoincrement=True),
            db.Column('name', db.String(length=255), nullable=False,
                      unique=True, index=True),
            db.Column('description', db.Text, nullable=True, default=''),
            db.Column('is_managed', db.Boolean(), default=False,
                      nullable=False),
            db.Column('privacy_policy', db.String(length=1), nullable=False),
            db.Column('subscription_policy', db.String(length=1),
                      nullable=False),
            db.Column('created', db.DateTime, nullable=False,
                      default=datetime.now),
            db.Column('modified', db.DateTime, nullable=False,
                      default=datetime.now, onupdate=datetime.now),
            db.PrimaryKeyConstraint('id'),
            mysql_charset='utf8',
            mysql_engine='MyISAM'
        )

    if op.has_table('user_usergroup'):
        op.rename_table(
            old_table_name='user_usergroup',
            new_table_name='groupMEMBER'
        )
        with op.batch_alter_table("groupMEMBER") as batch_op:
            batch_op.drop_index('id_usergroup')
            batch_op.alter_column('id_user', server_default=None)
            batch_op.alter_column(
                column_name='id_usergroup', new_column_name='id_group',
                existing_type=db.Integer(15, unsigned=True),
                nullable=False
            )
            batch_op.create_index('id_group', ['id_group'])
            batch_op.alter_column(
                column_name='user_status', new_column_name='state',
                type_=db.String(length=1), nullable=False
            )
            batch_op.drop_column('user_status_date')
            batch_op.add_column(db.Column('modified', db.DateTime(),
                                nullable=False, default=datetime.now,
                                onupdate=datetime.now))
            batch_op.add_column(db.Column('created', db.DateTime(),
                                nullable=False, default=datetime.now))
    else:
        op.create_table(
            'groupMEMBER',
            db.Column('id_user', db.Integer(15, unsigned=True),
                      nullable=False),
            db.Column('id_group', db.Integer(15, unsigned=True)),
            db.Column('state', db.String(length=1), nullable=False),
            db.Column('created', db.DateTime(), nullable=False,
                      default=datetime.now),
            db.Column('modified', db.DateTime(), nullable=False,
                      default=datetime.now, onupdate=datetime.now),
            db.ForeignKeyConstraint(['id_group'], [u'group.id'], ),
            db.ForeignKeyConstraint(['id_user'], [u'user.id'], ),
            db.PrimaryKeyConstraint('id_user', 'id_group'),
            mysql_charset='utf8',
            mysql_engine='MyISAM'
        )

    op.create_table(
        'groupADMIN',
        db.Column('id', db.Integer(15, unsigned=True), nullable=False,
                  autoincrement=True),
        db.Column('group_id', db.Integer(15, unsigned=True)),
        db.Column('admin_type', db.Unicode(255)),
        db.Column('admin_id', db.Integer),
        db.ForeignKeyConstraint(['group_id'], [u'group.id'], ),
        db.PrimaryKeyConstraint('id', 'group_id'),
        mysql_charset='utf8',
        mysql_engine='MyISAM'
    )
def do_upgrade():
    """Implement your upgrades here."""
    with op.batch_alter_table("bwlWORKFLOWLOGGING") as batch_op:
        batch_op.alter_column(column_name="id_object", type_=db.String(36), nullable=False)
def do_upgrade():
    """Implement your upgrades here."""
    with op.batch_alter_table("UserEXT") as batch_op:
        batch_op.alter_column(column_name='id',
                              type_=db.String(255),
                              nullable=False)