def do_upgrade():
    """Implement your upgrades here."""
    if not op.has_table('pidSTORE'):
        op.create_table(
            'pidSTORE',
            sa.Column('id', mysql.INTEGER(display_width=15), nullable=False),
            sa.Column('pid_type', sa.String(length=6), nullable=False),
            sa.Column('pid_value', sa.String(length=255), nullable=False),
            sa.Column('pid_provider', sa.String(length=255), nullable=False),
            sa.Column('status', sa.CHAR(length=1), nullable=False, index=True),
            sa.Column('object_type', sa.String(length=3), nullable=True),
            sa.Column('object_value', sa.String(length=255), nullable=True),
            sa.Column('created', sa.DateTime(), nullable=False),
            sa.Column('last_modified', sa.DateTime(), nullable=False),
            sa.PrimaryKeyConstraint('id'),
            sa.Index('idx_object', 'object_type', 'object_value', unique=False),
            sa.Index('uidx_type_pid', 'pid_type', 'pid_value', unique=True),
        )
    else:
        warnings.warn("*** Creation of 'pidSTORE' table skipped! ***")

    if not op.has_table('pidLOG'):
        op.create_table(
            'pidLOG',
            sa.Column('id', mysql.INTEGER(display_width=15), nullable=False),
            sa.Column('id_pid', mysql.INTEGER(display_width=15), nullable=True),
            sa.Column('timestamp', sa.DateTime(), nullable=False),
            sa.Column('action', sa.String(length=10), nullable=False, index=True),
            sa.Column('message', sa.Text(), nullable=False),
            sa.ForeignKeyConstraint(['id_pid'], ['pidSTORE.id'], ),
            sa.PrimaryKeyConstraint('id')
        )
    else:
        warnings.warn("*** Creation of 'pidLOG' table skipped! ***")
def do_upgrade():
    """ Implement your upgrades here  """
    if not op.has_table('remoteACCOUNT'):
        op.create_table(
            'remoteACCOUNT',
            db.Column('id', db.Integer(display_width=15), nullable=False),
            db.Column('user_id', db.Integer(display_width=15), nullable=False),
            db.Column('client_id', db.String(length=255), nullable=False),
            db.Column('extra_data', db.JSON, nullable=True),
            db.ForeignKeyConstraint(['user_id'], ['user.id'], ),
            db.PrimaryKeyConstraint('id'),
            db.UniqueConstraint('user_id', 'client_id'),
            mysql_charset='utf8',
            mysql_engine='MyISAM'
        )
    else:
        warnings.warn("*** Creation of table 'remoteACCOUNT table skipped!'")

    if not op.has_table('remoteTOKEN'):
        op.create_table(
            'remoteTOKEN',
            db.Column('id_remote_account', db.Integer(display_width=15),
                      nullable=False),
            db.Column('token_type', db.String(length=40), nullable=False),
            db.Column('access_token', db.Text(), nullable=False),
            db.Column('secret', db.Text(), nullable=False),
            db.ForeignKeyConstraint(['id_remote_account'],
                                    ['remoteACCOUNT.id'], ),
            db.PrimaryKeyConstraint('id_remote_account', 'token_type'),
            mysql_charset='utf8',
            mysql_engine='MyISAM'
        )
    else:
        warnings.warn("*** Creation of table 'remoteTOKEN' skipped!'")
def do_upgrade():
    """ Implement your upgrades here  """
    if not op.has_table('remoteACCOUNT'):
        op.create_table(
            'remoteACCOUNT',
            db.Column('id', db.Integer(display_width=15), nullable=False),
            db.Column('user_id', db.Integer(display_width=15), nullable=False),
            db.Column('client_id', db.String(length=255), nullable=False),
            db.Column('extra_data', db.JSON, nullable=True),
            db.ForeignKeyConstraint(['user_id'], ['user.id'], ),
            db.PrimaryKeyConstraint('id'),
            db.UniqueConstraint('user_id', 'client_id'),
            mysql_charset='utf8',
            mysql_engine='MyISAM'
        )
    else:
        warnings.warn("*** Creation of table 'remoteACCOUNT table skipped!'")

    if not op.has_table('remoteTOKEN'):
        op.create_table(
            'remoteTOKEN',
            db.Column('id_remote_account', db.Integer(display_width=15),
                    nullable=False),
            db.Column('token_type', db.String(length=40), nullable=False),
            db.Column('access_token', db.Text(), nullable=False),
            db.Column('secret', db.Text(), nullable=False),
            db.ForeignKeyConstraint(['id_remote_account'],
                                    ['remoteACCOUNT.id'], ),
            db.PrimaryKeyConstraint('id_remote_account', 'token_type'),
            mysql_charset='utf8',
            mysql_engine='MyISAM'
        )
    else:
        warnings.warn("*** Creation of table 'remoteTOKEN' skipped!'")
Ejemplo n.º 4
0
def do_upgrade():
    """Implement your upgrades here."""
    if not op.has_table('oauth2CLIENT'):
        op.create_table(
            'oauth2CLIENT',
            db.Column('name', db.String(length=40), nullable=True),
            db.Column('description', db.Text(), nullable=True),
            db.Column('website', URLType(), nullable=True),
            db.Column('user_id', db.Integer(15, unsigned=True), nullable=True),
            db.Column('client_id', db.String(length=255), nullable=False),
            db.Column('client_secret', db.String(length=255), nullable=False),
            db.Column('is_confidential', db.Boolean(), nullable=True),
            db.Column('is_internal', db.Boolean(), nullable=True),
            db.Column('_redirect_uris', db.Text(), nullable=True),
            db.Column('_default_scopes', db.Text(), nullable=True),
            db.ForeignKeyConstraint(['user_id'], ['user.id'], ),
            db.PrimaryKeyConstraint('client_id'),
            mysql_charset='utf8',
            mysql_engine='MyISAM'
        )
    else:
        warnings.warn("*** Creation of table 'oauth2CLIENT' skipped!")

    if not op.has_table('oauth2TOKEN'):
        op.create_table(
            'oauth2TOKEN',
            db.Column('id', db.Integer(15, unsigned=True), autoincrement=True,
                      nullable=False),
            db.Column('client_id', db.String(length=40), nullable=False),
            db.Column('user_id', db.Integer(15, unsigned=True), nullable=True),
            db.Column('token_type', db.String(length=255), nullable=True),
            db.Column('access_token', db.String(length=255), nullable=True),
            db.Column('refresh_token', db.String(length=255), nullable=True),
            db.Column('expires', db.DateTime(), nullable=True),
            db.Column('_scopes', db.Text(), nullable=True),
            db.Column('is_personal', db.Boolean(), nullable=True),
            db.Column('is_internal', db.Boolean(), nullable=True),
            db.ForeignKeyConstraint(
                ['client_id'], ['oauth2CLIENT.client_id'],),
            db.ForeignKeyConstraint(['user_id'], ['user.id'], ),
            db.PrimaryKeyConstraint('id'),
            db.UniqueConstraint('access_token'),
            db.UniqueConstraint('refresh_token'),
            mysql_charset='utf8',
            mysql_engine='MyISAM'
        )
    else:
        warnings.warn("*** Creation of table 'oauth2TOKEN' skipped!")
def estimate():
    """Estimate running time of upgrade in seconds (optional)."""
    if op.has_table('remoteTOKEN'):
        return run_sql(
            "SELECT COUNT(*) AS ids FROM remoteTOKEN"
        )[0][0]
    return 1
def pre_upgrade():
    """Run pre-upgrade checks (optional)."""
    table = "record_json"
    if op.has_table(table):
        warnings.warn(
            "*** Table {0} already exists! *** " "This upgrade will *NOT* create the new table.".format(table)
        )
Ejemplo n.º 7
0
def pre_upgrade():
    """Run pre-upgrade checks (optional)."""
    table = "record_json"
    if op.has_table(table):
        warnings.warn(
            "*** Table {0} already exists! *** "
            "This upgrade will *NOT* create the new table.".format(table))
def do_upgrade():
    """ Implement your upgrades here  """
    if not op.has_table("oauth2CLIENT"):
        op.create_table(
            "oauth2CLIENT",
            db.Column("name", db.String(length=40), nullable=True),
            db.Column("description", db.Text(), nullable=True),
            db.Column("website", URLType(), nullable=True),
            db.Column("user_id", db.Integer(15, unsigned=True), nullable=True),
            db.Column("client_id", db.String(length=255), nullable=False),
            db.Column("client_secret", db.String(length=255), nullable=False),
            db.Column("is_confidential", db.Boolean(), nullable=True),
            db.Column("is_internal", db.Boolean(), nullable=True),
            db.Column("_redirect_uris", db.Text(), nullable=True),
            db.Column("_default_scopes", db.Text(), nullable=True),
            db.ForeignKeyConstraint(["user_id"], ["user.id"]),
            db.PrimaryKeyConstraint("client_id"),
            mysql_charset="utf8",
            mysql_engine="MyISAM",
        )
    else:
        warnings.warn("*** Creation of table 'oauth2CLIENT' skipped!")

    if not op.has_table("oauth2TOKEN"):
        op.create_table(
            "oauth2TOKEN",
            db.Column("id", db.Integer(15, unsigned=True), autoincrement=True, nullable=False),
            db.Column("client_id", db.String(length=40), nullable=False),
            db.Column("user_id", db.Integer(15, unsigned=True), nullable=True),
            db.Column("token_type", db.String(length=255), nullable=True),
            db.Column("access_token", db.String(length=255), nullable=True),
            db.Column("refresh_token", db.String(length=255), nullable=True),
            db.Column("expires", db.DateTime(), nullable=True),
            db.Column("_scopes", db.Text(), nullable=True),
            db.Column("is_personal", db.Boolean(), nullable=True),
            db.Column("is_internal", db.Boolean(), nullable=True),
            db.ForeignKeyConstraint(["client_id"], ["oauth2CLIENT.client_id"]),
            db.ForeignKeyConstraint(["user_id"], ["user.id"]),
            db.PrimaryKeyConstraint("id"),
            db.UniqueConstraint("access_token"),
            db.UniqueConstraint("refresh_token"),
            mysql_charset="utf8",
            mysql_engine="MyISAM",
        )
    else:
        warnings.warn("*** Creation of table 'oauth2TOKEN' skipped!")
def do_upgrade():
    """Implement your upgrades here."""
    if not op.has_table("wtgTAG"):
        op.create_table(
            'wtgTAG',
            sa.Column('id', mysql.INTEGER(display_width=15), nullable=False),
            sa.Column('name', sa.String(length=255),
                      server_default='', nullable=False, index=True),
            sa.Column('id_user', mysql.INTEGER(display_width=15),
                      server_default='0', nullable=True),
            sa.Column('user_access_rights', mysql.INTEGER(
                display_width=2), nullable=False),
            sa.Column('id_usergroup', mysql.INTEGER(
                display_width=15), server_default='0', nullable=True),
            sa.Column('group_access_rights', mysql.INTEGER(
                display_width=2), nullable=False),
            sa.Column('public_access_rights', mysql.INTEGER(
                display_width=2), nullable=False),
            sa.Column('show_in_description', sa.Boolean(), nullable=False),
            sa.ForeignKeyConstraint(['id_user'], ['user.id'], ),
            sa.ForeignKeyConstraint(['id_usergroup'], ['usergroup.id'], ),
            sa.PrimaryKeyConstraint('id'),
            mysql_charset='utf8',
            mysql_engine='MyISAM'
        )
    else:
        warnings.warn("*** Creation of 'wtgTAG' table skipped! ***")

    if not op.has_table("wtgTAG_bibrec"):
        op.create_table(
            'wtgTAG_bibrec',
            sa.Column(
                'id_tag', mysql.INTEGER(display_width=15), nullable=False),
            sa.Column(
                'id_bibrec', mysql.INTEGER(display_width=15), nullable=False),
            sa.Column(
                'annotation', sa.Text(convert_unicode=True), nullable=True),
            sa.Column('date_added', sa.DateTime(), nullable=True),
            sa.ForeignKeyConstraint(['id_bibrec'], ['bibrec.id'], ),
            sa.ForeignKeyConstraint(['id_tag'], ['wtgTAG.id'], ),
            sa.PrimaryKeyConstraint('id_tag', 'id_bibrec'),
            mysql_charset='utf8',
            mysql_engine='MyISAM'
        )
    else:
        warnings.warn("*** Creation of 'wtgTAG_bibrec' table skipped! ***")
Ejemplo n.º 10
0
def pre_upgrade():
    """Run pre-upgrade checks (optional)."""
    tables = ["wtgTAG", "wtgTAG_bibrec"]
    for table in tables:
        if op.has_table(table):
            warnings.warn(
                "*** Table {0} already exists! *** "
                "This upgrade will *NOT* create the new table.".format(table))
def pre_upgrade():
    """Run pre-upgrade checks (optional)."""
    tables = ["wtgTAG", "wtgTAG_bibrec"]
    for table in tables:
        if op.has_table(table):
            warnings.warn(
                "*** Table {0} already exists! *** "
                "This upgrade will *NOT* create the new table.".format(table)
            )
Ejemplo n.º 12
0
def pre_upgrade():
    """Run pre-upgrade checks (optional)."""
    tables = ["bwlWORKFLOW", "bwlOBJECT", "bwlWORKFLOWLOGGING", "bwlOBJECTLOGGING"]
    for table in tables:
        if op.has_table(table):
            warnings.warn(
                "*** Table {0} already exists! *** "
                "This upgrade will *NOT* create the new table.".format(table)
            )
Ejemplo n.º 13
0
def clean_sessions():
    """
    Deletes expired sessions only.
    """
    if op.has_table('session') and not CFG_INSPIRE_SITE:
        deleted_sessions = 0
        timelimit = convert_datestruct_to_datetext(time.gmtime())
        write_message("Deleting expired sessions since %s" % (timelimit, ))

        query = "DELETE FROM session WHERE session_expiry < %s"
        write_message(query % (timelimit, ), verbose=9)
        deleted_sessions += run_sql(query, (timelimit, ))

        write_message("Deleted %d sessions" % (deleted_sessions, ))
def do_upgrade():
    """Implement your upgrades here."""
    if not op.has_table("record_json"):
        op.create_table(
            "record_json",
            sa.Column("id", db.MediumInteger(8, unsigned=True), nullable=False),
            sa.Column("json", db.JSON, nullable=False),
            sa.ForeignKeyConstraint(["id"], ["bibrec.id"]),
            sa.PrimaryKeyConstraint("id"),
            mysql_charset="utf8",
            mysql_engine="MyISAM",
        )
    else:
        warnings.warn("*** Creation of 'record_json' table skipped! ***")
Ejemplo n.º 15
0
def clean_sessions():
    """
    Deletes expired sessions only.
    """
    if op.has_table('session') and not CFG_INSPIRE_SITE:
        deleted_sessions = 0
        timelimit = convert_datestruct_to_datetext(time.gmtime())
        write_message("Deleting expired sessions since %s" % (timelimit,))

        query = "DELETE FROM session WHERE session_expiry < %s"
        write_message(query % (timelimit,), verbose=9)
        deleted_sessions += run_sql(query, (timelimit,))

        write_message("Deleted %d sessions" % (deleted_sessions,))
def do_upgrade():
    """Implement your upgrades here."""
    if not op.has_table("record_json"):
        op.create_table(
            'record_json',
            sa.Column('id', db.MediumInteger(8, unsigned=True),
                      nullable=False),
            sa.Column('json', db.JSON, nullable=False),
            sa.ForeignKeyConstraint(['id'], ['bibrec.id'], ),
            sa.PrimaryKeyConstraint('id'),
            mysql_charset='utf8',
            mysql_engine='MyISAM'
        )
    else:
        warnings.warn("*** Creation of 'record_json' table skipped! ***")
def do_upgrade():
    """Add the table with facets configuration."""
    if not op.has_table('facet_collection'):
        op.create_table(
            'facet_collection',
            db.Column('id', mysql.INTEGER(), nullable=False),
            db.Column('id_collection', mysql.INTEGER(), nullable=False),
            db.Column('order', mysql.INTEGER(), nullable=False),
            db.Column('facet_name', db.String(length=80), nullable=False),
            db.ForeignKeyConstraint(['id_collection'], ['collection.id'], ),
            db.PrimaryKeyConstraint('id'),
            mysql_charset='utf8',
            mysql_engine='MyISAM'
        )
    else:
        warnings.warn("*** Creation of table 'facet_collection' skipped!")
Ejemplo n.º 18
0
def do_upgrade():
    """Implement your upgrades here."""
    if not op.has_table("record_json"):
        op.create_table('record_json',
                        sa.Column('id',
                                  db.MediumInteger(8, unsigned=True),
                                  nullable=False),
                        sa.Column('json', db.JSON, nullable=False),
                        sa.ForeignKeyConstraint(
                            ['id'],
                            ['bibrec.id'],
                        ),
                        sa.PrimaryKeyConstraint('id'),
                        mysql_charset='utf8',
                        mysql_engine='MyISAM')
    else:
        warnings.warn("*** Creation of 'record_json' table skipped! ***")
Ejemplo n.º 19
0
def do_upgrade():
    """Add the table with facets configuration."""
    if not op.has_table('facet_collection'):
        op.create_table('facet_collection',
                        db.Column('id', mysql.INTEGER(), nullable=False),
                        db.Column('id_collection',
                                  mysql.INTEGER(),
                                  nullable=False),
                        db.Column('order', mysql.INTEGER(), nullable=False),
                        db.Column('facet_name',
                                  db.String(length=80),
                                  nullable=False),
                        db.ForeignKeyConstraint(
                            ['id_collection'],
                            ['collection.id'],
                        ),
                        db.PrimaryKeyConstraint('id'),
                        mysql_charset='utf8',
                        mysql_engine='MyISAM')
    else:
        warnings.warn("*** Creation of table 'facet_collection' skipped!")
Ejemplo n.º 20
0
def do_upgrade():
    """Implement your upgrades here."""
    if not op.has_table('bwlWORKFLOW'):
        op.create_table(
            'bwlWORKFLOW',
            sa.Column('uuid', sa.String(length=36), nullable=False),
            sa.Column('name', sa.String(length=255), nullable=False),
            sa.Column('created', sa.DateTime(), nullable=False),
            sa.Column('modified', sa.DateTime(), nullable=False),
            sa.Column('id_user', mysql.INTEGER(), nullable=False),
            sa.Column('_extra_data', sa.LargeBinary(), nullable=False),
            sa.Column('status', mysql.INTEGER(), nullable=False),
            sa.Column(
                'current_object', mysql.INTEGER(), nullable=False),
            sa.Column(
                'counter_initial', mysql.INTEGER(), nullable=False),
            sa.Column(
                'counter_halted', mysql.INTEGER(), nullable=False),
            sa.Column(
                'counter_error', mysql.INTEGER(), nullable=False),
            sa.Column(
                'counter_finished', mysql.INTEGER(), nullable=False),
            sa.Column(
                'module_name', sa.String(length=64), nullable=False),
            sa.PrimaryKeyConstraint('uuid'),
            mysql_charset='utf8',
            mysql_engine='MyISAM'
        )
    else:
        warnings.warn("*** Creation of 'bwlWORKFLOW' table skipped! ***")

    if not op.has_table('bwlOBJECT'):
        op.create_table(
            'bwlOBJECT',
            sa.Column('id', mysql.INTEGER(), nullable=False),
            sa.Column('_data', sa.LargeBinary(), nullable=False),
            sa.Column('_extra_data', sa.LargeBinary(), nullable=False),
            sa.Column(
                'id_workflow', sa.String(length=36), nullable=True),
            sa.Column(
                'version', mysql.INTEGER(display_width=3), nullable=False),
            sa.Column('id_parent', mysql.INTEGER(), nullable=True),
            sa.Column('created', sa.DateTime(), nullable=False),
            sa.Column('modified', sa.DateTime(), nullable=False),
            sa.Column('status', sa.String(length=255), nullable=False),
            sa.Column(
                'data_type', sa.String(length=150), nullable=True),
            sa.Column('uri', sa.String(length=500), nullable=True),
            sa.Column('id_user', mysql.INTEGER(), nullable=False),
            sa.ForeignKeyConstraint(['id_parent'], ['bwlOBJECT.id'], ),
            sa.ForeignKeyConstraint(
                ['id_workflow'], ['bwlWORKFLOW.uuid'], ),
            sa.PrimaryKeyConstraint('id'),
            mysql_charset='utf8',
            mysql_engine='MyISAM'
        )
    else:
        warnings.warn("*** Creation of 'bwlOBJECT' table skipped! ***")

    if not op.has_table('bwlWORKFLOWLOGGING'):
        op.create_table(
            'bwlWORKFLOWLOGGING',
            sa.Column('id', mysql.INTEGER(), nullable=False),
            sa.Column(
                'id_object', sa.String(length=255), nullable=False),
            sa.Column('log_type', mysql.INTEGER(), nullable=False),
            sa.Column('created', sa.DateTime(), nullable=True),
            sa.Column('message', sa.TEXT(), nullable=False),
            sa.ForeignKeyConstraint(
                ['id_object'], ['bwlWORKFLOW.uuid'], ),
            sa.PrimaryKeyConstraint('id'),
            mysql_charset='utf8',
            mysql_engine='MyISAM'
        )
    else:
        warnings.warn("*** Creation of 'bwlWORKFLOWLOGGING' table skipped! ***")

    if not op.has_table('bwlOBJECTLOGGING'):
        op.create_table(
            'bwlOBJECTLOGGING',
            sa.Column('id', mysql.INTEGER(), nullable=False),
            sa.Column('id_object', mysql.INTEGER(
                display_width=255), nullable=False),
            sa.Column('log_type', mysql.INTEGER(), nullable=False),
            sa.Column('created', sa.DateTime(), nullable=True),
            sa.Column('message', sa.TEXT(), nullable=False),
            sa.ForeignKeyConstraint(['id_object'], ['bwlOBJECT.id'], ),
            sa.PrimaryKeyConstraint('id'),
            mysql_charset='utf8',
            mysql_engine='MyISAM'
        )
    else:
        warnings.warn("*** Creation of 'bwlOBJECTLOGGING' table skipped! ***")
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."""
    if not op.has_table('bwlWORKFLOW'):
        op.create_table(
            'bwlWORKFLOW',
            sa.Column('uuid', sa.String(length=36), nullable=False),
            sa.Column('name', sa.String(length=255), nullable=False),
            sa.Column('created', sa.DateTime(), nullable=False),
            sa.Column('modified', sa.DateTime(), nullable=False),
            sa.Column('id_user', mysql.INTEGER(), nullable=False),
            sa.Column('_extra_data', sa.LargeBinary(), nullable=False),
            sa.Column('status', mysql.INTEGER(), nullable=False),
            sa.Column(
                'current_object', mysql.INTEGER(), nullable=False),
            sa.Column(
                'counter_initial', mysql.INTEGER(), nullable=False),
            sa.Column(
                'counter_halted', mysql.INTEGER(), nullable=False),
            sa.Column(
                'counter_error', mysql.INTEGER(), nullable=False),
            sa.Column(
                'counter_finished', mysql.INTEGER(), nullable=False),
            sa.Column(
                'module_name', sa.String(length=64), nullable=False),
            sa.PrimaryKeyConstraint('uuid'),
            mysql_charset='utf8',
            mysql_engine='MyISAM'
        )
    else:
        warnings.warn("*** Creation of 'bwlWORKFLOW' table skipped! ***")

    if not op.has_table('bwlOBJECT'):
        op.create_table(
            'bwlOBJECT',
            sa.Column('id', mysql.INTEGER(), nullable=False),
            sa.Column('_data', sa.LargeBinary(), nullable=False),
            sa.Column('_extra_data', sa.LargeBinary(), nullable=False),
            sa.Column(
                'id_workflow', sa.String(length=36), nullable=True),
            sa.Column(
                'version', mysql.INTEGER(display_width=3), nullable=False),
            sa.Column('id_parent', mysql.INTEGER(), nullable=True),
            sa.Column('created', sa.DateTime(), nullable=False),
            sa.Column('modified', sa.DateTime(), nullable=False),
            sa.Column('status', sa.String(length=255), nullable=False),
            sa.Column(
                'data_type', sa.String(length=150), nullable=True),
            sa.Column('uri', sa.String(length=500), nullable=True),
            sa.Column('id_user', mysql.INTEGER(), nullable=False),
            sa.ForeignKeyConstraint(['id_parent'], ['bwlOBJECT.id'], ),
            sa.ForeignKeyConstraint(
                ['id_workflow'], ['bwlWORKFLOW.uuid'], ),
            sa.PrimaryKeyConstraint('id'),
            mysql_charset='utf8',
            mysql_engine='MyISAM'
        )
    else:
        warnings.warn("*** Creation of 'bwlOBJECT' table skipped! ***")

    if not op.has_table('bwlWORKFLOWLOGGING'):
        op.create_table(
            'bwlWORKFLOWLOGGING',
            sa.Column('id', mysql.INTEGER(), nullable=False),
            sa.Column(
                'id_object', sa.String(length=255), nullable=False),
            sa.Column('log_type', mysql.INTEGER(), nullable=False),
            sa.Column('created', sa.DateTime(), nullable=True),
            sa.Column('message', sa.TEXT(), nullable=False),
            sa.ForeignKeyConstraint(
                ['id_object'], ['bwlWORKFLOW.uuid'], ),
            sa.PrimaryKeyConstraint('id'),
            mysql_charset='utf8',
            mysql_engine='MyISAM'
        )
    else:
        warnings.warn(
            "*** Creation of 'bwlWORKFLOWLOGGING' table skipped! ***")

    if not op.has_table('bwlOBJECTLOGGING'):
        op.create_table(
            'bwlOBJECTLOGGING',
            sa.Column('id', mysql.INTEGER(), nullable=False),
            sa.Column('id_object', mysql.INTEGER(
                display_width=255), nullable=False),
            sa.Column('log_type', mysql.INTEGER(), nullable=False),
            sa.Column('created', sa.DateTime(), nullable=True),
            sa.Column('message', sa.TEXT(), nullable=False),
            sa.ForeignKeyConstraint(['id_object'], ['bwlOBJECT.id'], ),
            sa.PrimaryKeyConstraint('id'),
            mysql_charset='utf8',
            mysql_engine='MyISAM'
        )
    else:
        warnings.warn("*** Creation of 'bwlOBJECTLOGGING' table skipped! ***")
def do_upgrade():
    """Implement your upgrades here."""
    if not op.has_table("audit_logging"):
        Audit.__table__.create(db.engine)
Ejemplo n.º 24
0
def estimate():
    """Estimate running time of upgrade in seconds (optional)."""
    if op.has_table('oauth2TOKEN'):
        return run_sql("SELECT COUNT(id) AS ids FROM oauth2TOKEN")[0][0]
    return 1
Ejemplo n.º 25
0
def do_upgrade():
    """Implement your upgrades here."""
    if not op.has_table("wtgTAG"):
        op.create_table('wtgTAG',
                        sa.Column('id',
                                  mysql.INTEGER(display_width=15),
                                  nullable=False),
                        sa.Column('name',
                                  sa.String(length=255),
                                  server_default='',
                                  nullable=False,
                                  index=True),
                        sa.Column('id_user',
                                  mysql.INTEGER(display_width=15),
                                  server_default='0',
                                  nullable=True),
                        sa.Column('user_access_rights',
                                  mysql.INTEGER(display_width=2),
                                  nullable=False),
                        sa.Column('id_usergroup',
                                  mysql.INTEGER(display_width=15),
                                  server_default='0',
                                  nullable=True),
                        sa.Column('group_access_rights',
                                  mysql.INTEGER(display_width=2),
                                  nullable=False),
                        sa.Column('public_access_rights',
                                  mysql.INTEGER(display_width=2),
                                  nullable=False),
                        sa.Column('show_in_description',
                                  sa.Boolean(),
                                  nullable=False),
                        sa.ForeignKeyConstraint(
                            ['id_user'],
                            ['user.id'],
                        ),
                        sa.ForeignKeyConstraint(
                            ['id_usergroup'],
                            ['usergroup.id'],
                        ),
                        sa.PrimaryKeyConstraint('id'),
                        mysql_charset='utf8',
                        mysql_engine='MyISAM')
    else:
        warnings.warn("*** Creation of 'wtgTAG' table skipped! ***")

    if not op.has_table("wtgTAG_bibrec"):
        op.create_table('wtgTAG_bibrec',
                        sa.Column('id_tag',
                                  mysql.INTEGER(display_width=15),
                                  nullable=False),
                        sa.Column('id_bibrec',
                                  mysql.INTEGER(display_width=15),
                                  nullable=False),
                        sa.Column('annotation',
                                  sa.Text(convert_unicode=True),
                                  nullable=True),
                        sa.Column('date_added', sa.DateTime(), nullable=True),
                        sa.ForeignKeyConstraint(
                            ['id_bibrec'],
                            ['bibrec.id'],
                        ),
                        sa.ForeignKeyConstraint(
                            ['id_tag'],
                            ['wtgTAG.id'],
                        ),
                        sa.PrimaryKeyConstraint('id_tag', 'id_bibrec'),
                        mysql_charset='utf8',
                        mysql_engine='MyISAM')
    else:
        warnings.warn("*** Creation of 'wtgTAG_bibrec' table skipped! ***")