コード例 #1
0
def do_upgrade():
    """ Implement your upgrades here  """
    op.rename_table('pid', 'pidSTORE')
    op.drop_index('idx_object_type_id', 'pidSTORE')
    op.alter_column(
        'pidSTORE', 'type',
        new_column_name='pid_type',
        existing_type=mysql.VARCHAR(length=6),
        nullable=False,
        existing_server_default='')
    op.alter_column(
        'pidSTORE', 'pid',
        new_column_name='pid_value',
        existing_type=mysql.VARCHAR(length=255),
        nullable=False,
        existing_server_default='')
    op.alter_column(
        'pidSTORE', 'object_id',
        new_column_name='object_value',
        existing_type=mysql.VARCHAR(length=255),
        nullable=True,
        existing_server_default='')
    op.add_column(
        'pidSTORE',
        db.Column('pid_provider', db.String(length=255), nullable=False)
    )
コード例 #2
0
def do_upgrade():
    """ Implement your upgrades here  """
    op.rename_table('pid', 'pidSTORE')
    op.drop_index('idx_object_type_id', 'pidSTORE')
    op.alter_column('pidSTORE',
                    'type',
                    new_column_name='pid_type',
                    existing_type=mysql.VARCHAR(length=6),
                    nullable=False,
                    existing_server_default='')
    op.alter_column('pidSTORE',
                    'pid',
                    new_column_name='pid_value',
                    existing_type=mysql.VARCHAR(length=255),
                    nullable=False,
                    existing_server_default='')
    op.alter_column('pidSTORE',
                    'object_id',
                    new_column_name='object_value',
                    existing_type=mysql.VARCHAR(length=255),
                    nullable=True,
                    existing_server_default='')
    op.add_column(
        'pidSTORE',
        db.Column('pid_provider', db.String(length=255), nullable=False))
コード例 #3
0
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'
    )
コード例 #4
0
def do_upgrade():
    op.rename_table('userCOLLECTION', 'community')
    from invenio.modules.communities.models import Community
    for obj in Community.query.all():
        obj.save_collections()
コード例 #5
0
def do_upgrade():
    op.rename_table('userCOLLECTION', 'community')
    from invenio.modules.communities.models import Community
    for obj in Community.query.all():
        obj.save_collections()