def upgrade(migrate_engine):
    metadata = sa.MetaData()
    metadata.bind = migrate_engine

    # Some property values and change comments can get too big
    # for the normal 1024 String limit.

    if migrate_engine.dialect.name == "postgresql":
        # changeset.alter_column has no effect on postgres, so we do this
        # with raw sql
        table_columns = [
            ('changes', 'comments'),
            ('buildset_properties', 'property_value'),
        ]
        for table, column in table_columns:
            migrate_engine.execute("alter table %s alter column %s type text" %
                                   (table, column))
    else:
        changeset.alter_column(sa.Column('property_value',
                                         sa.Text,
                                         nullable=False),
                               table='buildset_properties',
                               metadata=metadata,
                               engine=migrate_engine)
        changeset.alter_column(sa.Column('comments', sa.Text, nullable=False),
                               table='changes',
                               metadata=metadata,
                               engine=migrate_engine)
Exemplo n.º 2
0
def remove_buildername(migrate_engine):

    metadata = sa.MetaData()
    metadata.bind = migrate_engine

    sautils.Table('builders', metadata, autoload=True)
    sautils.Table('buildsets', metadata, autoload=True)
    buildrequests = sautils.Table('buildrequests', metadata, autoload=True)

    # Specify what the new table should look like
    buildrequests.c.buildername.drop()

    changeset.alter_column(sa.Column('builderid',
                                     sa.Integer,
                                     sa.ForeignKey("builders.id"),
                                     nullable=False),
                           table=buildrequests,
                           metadata=metadata,
                           engine=migrate_engine)

    idx = sa.Index('buildrequests_builderid', buildrequests.c.builderid)
    idx.create(migrate_engine)
    idx = sa.Index('buildrequests_buildsetid', buildrequests.c.buildsetid)
    idx.create(migrate_engine)
    idx = sa.Index('buildrequests_complete', buildrequests.c.complete)
    idx.create(migrate_engine)
def upgrade(migrate_engine):
    metadata = sa.MetaData()
    metadata.bind = migrate_engine

    # Some property values and change comments can get too big
    # for the normal 1024 String limit.

    if migrate_engine.dialect.name == "postgresql":
        # changeset.alter_column has no effect on postgres, so we do this
        # with raw sql
        table_columns = [
            ('changes', 'comments'),
            ('buildset_properties', 'property_value'),
        ]
        for table, column in table_columns:
            migrate_engine.execute("alter table %s alter column %s type text"
                                    % (table, column))
    else:
        changeset.alter_column(
                sa.Column('property_value', sa.Text, nullable=False),
                table='buildset_properties',
                metadata=metadata,
                engine=migrate_engine)
        changeset.alter_column(
                sa.Column('comments', sa.Text, nullable=False),
                table='changes',
                metadata=metadata,
                engine=migrate_engine)
def remove_buildername(migrate_engine):

    metadata = sa.MetaData()
    metadata.bind = migrate_engine

    sautils.Table('builders', metadata, autoload=True)
    sautils.Table('buildsets', metadata, autoload=True)
    buildrequests = sautils.Table('buildrequests', metadata, autoload=True)

    # Specify what the new table should look like
    buildrequests.c.buildername.drop()

    changeset.alter_column(
        sa.Column('builderid', sa.Integer, sa.ForeignKey(
            "builders.id"), nullable=False),
        table=buildrequests,
        metadata=metadata,
        engine=migrate_engine)

    idx = sa.Index('buildrequests_builderid', buildrequests.c.builderid)
    idx.create(migrate_engine)
    idx = sa.Index('buildrequests_buildsetid', buildrequests.c.buildsetid)
    idx.create(migrate_engine)
    idx = sa.Index('buildrequests_complete', buildrequests.c.complete)
    idx.create(migrate_engine)
def upgrade(migrate_engine):
    metadata = sa.MetaData()
    metadata.bind = migrate_engine

    changeset.alter_column(sa.Column('value_json',
                                     bsa.LongText,
                                     nullable=False),
                           table='object_state',
                           metadata=metadata,
                           engine=migrate_engine)
Exemplo n.º 6
0
def remove_buildername(migrate_engine):

    metadata = sa.MetaData()
    metadata.bind = migrate_engine

    sa.Table('builders', metadata, autoload=True)
    sa.Table('buildsets', metadata, autoload=True)

    # Specify what the new table should look like
    buildrequests = sa.Table(
        'buildrequests',
        metadata,
        sa.Column('id', sa.Integer, primary_key=True),
        sa.Column('buildsetid',
                  sa.Integer,
                  sa.ForeignKey("buildsets.id"),
                  nullable=False),
        sa.Column('builderid',
                  sa.Integer,
                  sa.ForeignKey('builders.id'),
                  nullable=False),
        sa.Column('priority',
                  sa.Integer,
                  nullable=False,
                  server_default=sa.DefaultClause("0")),
        sa.Column('complete', sa.Integer,
                  server_default=sa.DefaultClause("0")),
        sa.Column('results', sa.SmallInteger),
        sa.Column('submitted_at', sa.Integer, nullable=False),
        sa.Column('complete_at', sa.Integer),
        sa.Column('waited_for',
                  sa.SmallInteger,
                  server_default=sa.DefaultClause("0")),
    )
    changeset.drop_column(sa.Column('buildername',
                                    sa.String(length=256),
                                    nullable=False),
                          table=buildrequests,
                          metadata=metadata,
                          engine=migrate_engine)

    changeset.alter_column(sa.Column('builderid',
                                     sa.Integer,
                                     sa.ForeignKey("builders.id"),
                                     nullable=False),
                           table='buildrequests',
                           metadata=metadata,
                           engine=migrate_engine)

    idx = sa.Index('buildrequests_builderid', buildrequests.c.builderid)
    idx.create(migrate_engine)
    idx = sa.Index('buildrequests_buildsetid', buildrequests.c.buildsetid)
    idx.create(migrate_engine)
    idx = sa.Index('buildrequests_complete', buildrequests.c.complete)
    idx.create(migrate_engine)
def upgrade(migrate_engine):
    metadata = sa.MetaData()
    metadata.bind = migrate_engine

    if migrate_engine.dialect.name == "postgresql":
        # changeset.alter_column has no effect on postgres, so we do this with
        # raw sql
        migrate_engine.execute(
            "alter table change_properties alter column property_value type text")

    else:
        # Commit messages can get too big for the normal 1024 String limit.
        changeset.alter_column(
            sa.Column('property_value', sa.Text, nullable=False),
            table='change_properties',
            metadata=metadata,
            engine=migrate_engine)
def upgrade(migrate_engine):
    metadata = sa.MetaData()
    metadata.bind = migrate_engine

    if migrate_engine.dialect.name == "postgresql":
        # changeset.alter_column has no effect on postgres, so we do this with
        # raw sql
        migrate_engine.execute(
            "alter table change_properties alter column property_value type text"
        )

    else:
        # Commit messages can get too big for the normal 1024 String limit.
        changeset.alter_column(sa.Column('property_value',
                                         sa.Text,
                                         nullable=False),
                               table='change_properties',
                               metadata=metadata,
                               engine=migrate_engine)
def remove_buildername(migrate_engine):

    metadata = sa.MetaData()
    metadata.bind = migrate_engine

    sa.Table('builders', metadata, autoload=True)
    sa.Table('buildsets', metadata, autoload=True)

    # Specify what the new table should look like
    buildrequests = sa.Table('buildrequests', metadata,
                             sa.Column('id', sa.Integer, primary_key=True),
                             sa.Column('buildsetid', sa.Integer, sa.ForeignKey("buildsets.id"),
                                       nullable=False),
                             sa.Column('builderid', sa.Integer, sa.ForeignKey('builders.id'),
                                       nullable=False),
                             sa.Column('priority', sa.Integer, nullable=False,
                                       server_default=sa.DefaultClause("0")),
                             sa.Column('complete', sa.Integer,
                                       server_default=sa.DefaultClause("0")),
                             sa.Column('results', sa.SmallInteger),
                             sa.Column('submitted_at', sa.Integer, nullable=False),
                             sa.Column('complete_at', sa.Integer),
                             sa.Column('waited_for', sa.SmallInteger,
                                       server_default=sa.DefaultClause("0")),
                             )
    changeset.drop_column(
        sa.Column('buildername', sa.String(length=256), nullable=False),
        table=buildrequests,
        metadata=metadata,
        engine=migrate_engine)

    changeset.alter_column(
        sa.Column('builderid', sa.Integer, sa.ForeignKey("builders.id"), nullable=False),
        table='buildrequests',
        metadata=metadata,
        engine=migrate_engine)

    idx = sa.Index('buildrequests_builderid', buildrequests.c.builderid)
    idx.create(migrate_engine)
    idx = sa.Index('buildrequests_buildsetid', buildrequests.c.buildsetid)
    idx.create(migrate_engine)
    idx = sa.Index('buildrequests_complete', buildrequests.c.complete)
    idx.create(migrate_engine)
Exemplo n.º 10
0
def upgrade(migrate_engine):
    metadata = sa.MetaData()
    metadata.bind = migrate_engine

    # the old (non-sqlalchemy-migrate) migration scripts messed up the
    # lengths of these columns, so fix them here.
    changeset.alter_column(
        sa.Column('class_name', sa.String(128), nullable=False),
        table="schedulers",
        metadata=metadata,
        engine=migrate_engine)

    changeset.alter_column(
        sa.Column('name', sa.String(128), nullable=False),
        table="schedulers",
        metadata=metadata,
        engine=migrate_engine)

    # sqlalchemy's reflection gets the server_defaults wrong, so this
    # table has to be included here.
    changes = sautils.Table('changes', metadata,
                            sa.Column(
                                'changeid', sa.Integer, primary_key=True),
                            sa.Column(
                                'author', sa.String(256), nullable=False),
                            sa.Column(
                                'comments', sa.String(1024), nullable=False),
                            sa.Column(
                                'is_dir', sa.SmallInteger, nullable=False),
                            sa.Column('branch', sa.String(256)),
                            sa.Column('revision', sa.String(256)),
                            sa.Column('revlink', sa.String(256)),
                            sa.Column(
                                'when_timestamp', sa.Integer, nullable=False),
                            sa.Column('category', sa.String(256)),
                            sa.Column('repository', sa.String(length=512), nullable=False,
                                      server_default=''),
                            sa.Column('project', sa.String(length=512), nullable=False,
                                      server_default=''),
                            )
    changeset.alter_column(
        sa.Column('author', sa.String(256), nullable=False),
        table=changes,
        metadata=metadata,
        engine=migrate_engine)
    changeset.alter_column(
        sa.Column('branch', sa.String(256)),
        table=changes,
        metadata=metadata,
        engine=migrate_engine)
Exemplo n.º 11
0
def upgrade(migrate_engine):
    metadata = sa.MetaData()
    metadata.bind = migrate_engine

    # the old (non-sqlalchemy-migrate) migration scripts messed up the
    # lengths of these columns, so fix them here.
    changeset.alter_column(sa.Column('class_name',
                                     sa.String(128),
                                     nullable=False),
                           table="schedulers",
                           metadata=metadata,
                           engine=migrate_engine)

    changeset.alter_column(sa.Column('name', sa.String(128), nullable=False),
                           table="schedulers",
                           metadata=metadata,
                           engine=migrate_engine)

    # sqlalchemy's reflection gets the server_defaults wrong, so this
    # table has to be included here.
    changes = sautils.Table(
        'changes',
        metadata,
        sa.Column('changeid', sa.Integer, primary_key=True),
        sa.Column('author', sa.String(256), nullable=False),
        sa.Column('comments', sa.String(1024), nullable=False),
        sa.Column('is_dir', sa.SmallInteger, nullable=False),
        sa.Column('branch', sa.String(256)),
        sa.Column('revision', sa.String(256)),
        sa.Column('revlink', sa.String(256)),
        sa.Column('when_timestamp', sa.Integer, nullable=False),
        sa.Column('category', sa.String(256)),
        sa.Column('repository',
                  sa.String(length=512),
                  nullable=False,
                  server_default=''),
        sa.Column('project',
                  sa.String(length=512),
                  nullable=False,
                  server_default=''),
    )
    changeset.alter_column(sa.Column('author', sa.String(256), nullable=False),
                           table=changes,
                           metadata=metadata,
                           engine=migrate_engine)
    changeset.alter_column(sa.Column('branch', sa.String(256)),
                           table=changes,
                           metadata=metadata,
                           engine=migrate_engine)
def upgrade(migrate_engine):
    metadata = sa.MetaData()
    metadata.bind = migrate_engine
    errors = sum([_incompatible_changes(metadata, migrate_engine),
                  _incompatible_object_state(metadata, migrate_engine),
                  _incompatible_users(metadata, migrate_engine)], [])
    if errors:
        raise ValueError("\n".join([""] + errors))
    if migrate_engine.dialect.name == 'postgresql':
        # Sql alchemy migrate does not apply changes on postgresql
        def reduce_table_column_length(table, column):
            return 'ALTER TABLE {0} ALTER COLUMN {1} TYPE character varying(255)'.format(table, column)
        for table, columns in {'changes': ['author', 'branch', 'revision', 'category'],
                               'object_state': ['name'],
                               'users': ['identifier']}.items():
            for column in columns:
                migrate_engine.execute(
                    reduce_table_column_length(table, column))
        return

    changeset.alter_column(
        sa.Column('author', sa.String(255), nullable=False),
        table='changes',
        metadata=metadata,
        engine=migrate_engine)

    changeset.alter_column(
        sa.Column('branch', sa.String(255)),
        table='changes',
        metadata=metadata,
        engine=migrate_engine)

    changeset.alter_column(
        sa.Column('revision', sa.String(255)),
        table='changes',
        metadata=metadata,
        engine=migrate_engine)

    changeset.alter_column(
        sa.Column('category', sa.String(255)),
        table='changes',
        metadata=metadata,
        engine=migrate_engine)

    changeset.alter_column(
        sa.Column('name', sa.String(255), nullable=False),
        table='object_state',
        metadata=metadata,
        engine=migrate_engine)

    changeset.alter_column(
        sa.Column('identifier', sa.String(255), nullable=False),
        table='users',
        metadata=metadata,
        engine=migrate_engine)
Exemplo n.º 13
0
Arquivo: 003.py Projeto: ccoss/fas
def downgrade():
	alter_column(col, type=Text) 
Exemplo n.º 14
0
Arquivo: 003.py Projeto: ccoss/fas
def upgrade():
	alter_column(col, type=UnicodeText)
Exemplo n.º 15
0
def downgrade():
    alter_column(col, type=Text)
Exemplo n.º 16
0
def downgrade():
    alter_column(hosts.c.language, type=VARCHAR(8))
Exemplo n.º 17
0
def upgrade(migrate_engine):

    # this only applies to postgres
    if migrate_engine.dialect.name != 'mysql':
        return

    metadata = sa.MetaData()
    metadata.bind = migrate_engine

    changeset.alter_column(sa.Column('buildername',
                                     sa.String(255),
                                     nullable=False),
                           table="buildrequests",
                           metadata=metadata,
                           engine=migrate_engine)

    changeset.alter_column(sa.Column('author', sa.String(255), nullable=False),
                           table="changes",
                           metadata=metadata,
                           engine=migrate_engine)

    changeset.alter_column(sa.Column('branch', sa.String(255)),
                           table="changes",
                           metadata=metadata,
                           engine=migrate_engine)

    changeset.alter_column(sa.Column('revision', sa.String(255)),
                           table="changes",
                           metadata=metadata,
                           engine=migrate_engine)

    changeset.alter_column(sa.Column('category', sa.String(255)),
                           table="changes",
                           metadata=metadata,
                           engine=migrate_engine)

    changeset.alter_column(sa.Column('identifier',
                                     sa.String(255),
                                     nullable=False),
                           table="users",
                           metadata=metadata,
                           engine=migrate_engine)

    changeset.alter_column(sa.Column('name', sa.String(255), nullable=False),
                           table="object_state",
                           metadata=metadata,
                           engine=migrate_engine)

    migrate_engine.execute("Alter table buildrequests ENGINE=InnoDB")
    migrate_engine.execute("Alter table buildsets ENGINE=InnoDB")
    migrate_engine.execute("Alter table sourcestampsets ENGINE=InnoDB")
    migrate_engine.execute("Alter table buildrequest_claims ENGINE=InnoDB")
    migrate_engine.execute("Alter table objects ENGINE=InnoDB")
    migrate_engine.execute("Alter table builds ENGINE=InnoDB")
    migrate_engine.execute("Alter table buildset_properties ENGINE=InnoDB")
    migrate_engine.execute("Alter table change_files ENGINE=InnoDB")
    migrate_engine.execute("Alter table changes ENGINE=InnoDB")
    migrate_engine.execute("Alter table change_properties ENGINE=InnoDB")
    migrate_engine.execute("Alter table change_users ENGINE=InnoDB")
    migrate_engine.execute("Alter table users ENGINE=InnoDB")
    migrate_engine.execute("Alter table mastersconfig ENGINE=InnoDB")
    migrate_engine.execute("Alter table migrate_version ENGINE=InnoDB")
    migrate_engine.execute("Alter table object_state ENGINE=InnoDB")
    migrate_engine.execute("Alter table users_info ENGINE=InnoDB")
    migrate_engine.execute("Alter table patches ENGINE=InnoDB")
    migrate_engine.execute("Alter table sourcestamps ENGINE=InnoDB")
    migrate_engine.execute("Alter table sourcestamp_changes ENGINE=InnoDB")
    migrate_engine.execute("Alter table scheduler_changes ENGINE=InnoDB")

    buildrequests_tbl = sa.Table('buildrequests', metadata, autoload=True)
    buildsets_tbl = sa.Table('buildsets', metadata, autoload=True)
    sourcestampsets_tbl = sa.Table('sourcestampsets', metadata, autoload=True)
    buildrequest_claims_tbl = sa.Table('buildrequest_claims',
                                       metadata,
                                       autoload=True)
    objects_tbl = sa.Table('objects', metadata, autoload=True)
    builds_tbl = sa.Table('builds', metadata, autoload=True)
    buildset_properties_tbl = sa.Table('buildset_properties',
                                       metadata,
                                       autoload=True)
    change_files_tbl = sa.Table('change_files', metadata, autoload=True)
    changes_tbl = sa.Table('changes', metadata, autoload=True)
    change_properties_tbl = sa.Table('change_properties',
                                     metadata,
                                     autoload=True)
    change_users_tbl = sa.Table('change_users', metadata, autoload=True)
    users_tbl = sa.Table('users', metadata, autoload=True)
    mastersconfig_tbl = sa.Table('mastersconfig', metadata, autoload=True)
    object_state_tbl = sa.Table('object_state', metadata, autoload=True)
    users_info_tbl = sa.Table('users_info', metadata, autoload=True)
    patches_tbl = sa.Table('patches', metadata, autoload=True)
    sourcestamps_tbl = sa.Table('sourcestamps', metadata, autoload=True)
    sourcestamp_changes_tbl = sa.Table('sourcestamp_changes',
                                       metadata,
                                       autoload=True)
    scheduler_changes_tbl = sa.Table('scheduler_changes',
                                     metadata,
                                     autoload=True)

    # add missing FK  constraints
    # buildrequests table
    cons = constraint.ForeignKeyConstraint([buildrequests_tbl.c.mergebrid],
                                           [buildrequests_tbl.c.id])
    tryDropConst(cons)
    cons.create()

    cons = constraint.ForeignKeyConstraint([buildrequests_tbl.c.startbrid],
                                           [buildrequests_tbl.c.id])
    tryDropConst(cons)
    cons.create()

    cons = constraint.ForeignKeyConstraint(
        [buildrequests_tbl.c.triggeredbybrid], [buildrequests_tbl.c.id])
    tryDropConst(cons)
    cons.create()

    cons = constraint.ForeignKeyConstraint([buildrequests_tbl.c.artifactbrid],
                                           [buildrequests_tbl.c.id])
    tryDropConst(cons)
    cons.create()

    cons = constraint.ForeignKeyConstraint([buildrequests_tbl.c.buildsetid],
                                           [buildsets_tbl.c.id])
    tryDropConst(cons)
    cons.create()

    # buildsets table
    cons = constraint.ForeignKeyConstraint([buildsets_tbl.c.sourcestampsetid],
                                           [sourcestampsets_tbl.c.id])
    tryDropConst(cons)
    cons.create()

    # buildrequest_claims table
    cons = constraint.ForeignKeyConstraint([buildrequest_claims_tbl.c.brid],
                                           [buildrequests_tbl.c.id])
    tryDropConst(cons)
    cons.create()

    cons = constraint.ForeignKeyConstraint(
        [buildrequest_claims_tbl.c.objectid], [objects_tbl.c.id])
    tryDropConst(cons)
    cons.create()

    # builds table
    cons = constraint.ForeignKeyConstraint([builds_tbl.c.brid],
                                           [buildrequests_tbl.c.id])
    tryDropConst(cons)
    cons.create()

    # buildset_properties table
    cons = constraint.ForeignKeyConstraint(
        [buildset_properties_tbl.c.buildsetid], [buildsets_tbl.c.id])
    tryDropConst(cons)
    cons.create()

    # change_files table
    cons = constraint.ForeignKeyConstraint([change_files_tbl.c.changeid],
                                           [changes_tbl.c.changeid])
    tryDropConst(cons)
    cons.create()

    # change_properties table
    cons = constraint.ForeignKeyConstraint([change_properties_tbl.c.changeid],
                                           [changes_tbl.c.changeid])
    tryDropConst(cons)
    cons.create()

    # change_users table
    cons = constraint.ForeignKeyConstraint([change_users_tbl.c.changeid],
                                           [changes_tbl.c.changeid])
    tryDropConst(cons)
    cons.create()

    cons = constraint.ForeignKeyConstraint([change_users_tbl.c.uid],
                                           [users_tbl.c.uid])
    tryDropConst(cons)
    cons.create()

    # mastersconfig table
    cons = constraint.ForeignKeyConstraint([mastersconfig_tbl.c.objectid],
                                           [objects_tbl.c.id])
    tryDropConst(cons)
    cons.create()

    # object_state table
    cons = constraint.ForeignKeyConstraint([object_state_tbl.c.objectid],
                                           [objects_tbl.c.id])
    tryDropConst(cons)
    cons.create()

    # users_info table
    cons = constraint.ForeignKeyConstraint([users_info_tbl.c.uid],
                                           [users_tbl.c.uid])
    tryDropConst(cons)
    cons.create()

    # sourcestamps table
    cons = constraint.ForeignKeyConstraint([sourcestamps_tbl.c.patchid],
                                           [patches_tbl.c.id])
    tryDropConst(cons)
    cons.create()

    cons = constraint.ForeignKeyConstraint(
        [sourcestamps_tbl.c.sourcestampsetid], [sourcestampsets_tbl.c.id])
    tryDropConst(cons)
    cons.create()

    # sourcestamp_changes table
    cons = constraint.ForeignKeyConstraint(
        [sourcestamp_changes_tbl.c.sourcestampid], [sourcestamps_tbl.c.id])
    tryDropConst(cons)
    cons.create()

    cons = constraint.ForeignKeyConstraint(
        [sourcestamp_changes_tbl.c.changeid], [changes_tbl.c.changeid])
    tryDropConst(cons)
    cons.create()

    # scheduler_changes table
    cons = constraint.ForeignKeyConstraint([scheduler_changes_tbl.c.objectid],
                                           [objects_tbl.c.id])
    tryDropConst(cons)
    cons.create()

    cons = constraint.ForeignKeyConstraint([scheduler_changes_tbl.c.changeid],
                                           [changes_tbl.c.changeid])
    tryDropConst(cons)
    cons.create()
Exemplo n.º 18
0
def upgrade():
    alter_column(hosts.c.language, type=VARCHAR(16))
Exemplo n.º 19
0
def upgrade():
    alter_column(hosts.c.language, type=VARCHAR(16))
Exemplo n.º 20
0
def downgrade():
    alter_column(hosts.c.language, type=VARCHAR(8))
Exemplo n.º 21
0
def upgrade():
    alter_column(col, type=UnicodeText)