def downgrade():
    drop_fk('recipe_task', ['task_id'])
    op.execute("""
        ALTER TABLE recipe_task
        DROP name,
        DROP version,
        DROP fetch_url,
        DROP fetch_subdir,
        MODIFY task_id INT NOT NULL
        """)
    op.create_foreign_key(None, 'recipe_task', 'task', ['task_id'], ['id'])
    op.execute(
        "DELETE FROM system_access_policy_rule WHERE permission = 'view'")
    drop_enum_value('system_access_policy_rule',
                    'permission',
                    'view',
                    nullable=False)
    op.drop_column('command_queue', 'quiescent_period')
    drop_index('command_queue', ['status'])
    op.drop_column('power', 'power_quiescent_period')
    op.alter_column('tg_user', 'password', type_=sa.Unicode(40))
    op.execute(
        "ALTER TABLE beaker_tag DROP PRIMARY KEY, ADD PRIMARY KEY (id, tag)")
    op.create_table('locked', sa.Column('id', sa.Integer(), primary_key=True))
    op.create_table('serial', sa.Column('id', sa.Integer(), primary_key=True))
    op.create_table('serial_type',
                    sa.Column('id', sa.Integer(), primary_key=True))
    op.create_table('install', sa.Column('id', sa.Integer(), primary_key=True))
def downgrade():
    drop_fk('recipe_task_comment', ['recipe_task_id'])
    op.alter_column('recipe_task_comment',
                    'recipe_task_id',
                    nullable=True,
                    existing_type=sa.Integer)
    op.create_foreign_key(None, 'recipe_task_comment', 'recipe_task',
                          ['recipe_task_id'], ['id'])
    drop_fk('recipe_task_comment', ['user_id'])
    op.drop_index('recipe_task_comment_user_id_fk',
                  table_name='recipe_task_comment')
    op.create_index('ix_recipe_task_comment_user_id', 'recipe_task_comment',
                    ['user_id'])
    op.alter_column('recipe_task_comment',
                    'user_id',
                    nullable=True,
                    existing_type=sa.Integer)
    op.create_foreign_key(None, 'recipe_task_comment', 'tg_user', ['user_id'],
                          ['user_id'])
    op.alter_column('recipe_task_comment',
                    'comment',
                    nullable=True,
                    type_=sa.UnicodeText())
    op.alter_column('recipe_task_comment',
                    'created',
                    nullable=True,
                    existing_type=sa.DateTime)
def upgrade():
    drop_fk('recipe_task_comment', ['recipe_task_id'])
    op.alter_column('recipe_task_comment',
                    'recipe_task_id',
                    nullable=False,
                    existing_type=sa.Integer)
    op.create_foreign_key('recipe_task_comment_recipe_task_id_fk',
                          'recipe_task_comment',
                          'recipe_task', ['recipe_task_id'], ['id'],
                          onupdate='CASCADE',
                          ondelete='CASCADE')
    drop_fk('recipe_task_comment', ['user_id'])
    op.drop_index('ix_recipe_task_comment_user_id',
                  table_name='recipe_task_comment')
    op.alter_column('recipe_task_comment',
                    'user_id',
                    nullable=False,
                    existing_type=sa.Integer)
    op.create_foreign_key('recipe_task_comment_user_id_fk',
                          'recipe_task_comment',
                          'tg_user', ['user_id'], ['user_id'],
                          onupdate='CASCADE',
                          ondelete='CASCADE')
    op.alter_column('recipe_task_comment',
                    'comment',
                    nullable=False,
                    type_=sa.Unicode(4000))
    op.alter_column('recipe_task_comment',
                    'created',
                    nullable=False,
                    existing_type=sa.DateTime)
def upgrade():
    drop_fk('system_activity', ['system_id'])
    op.alter_column('system_activity',
                    'system_id',
                    existing_type=sa.Integer,
                    nullable=False)
    op.create_foreign_key(None, 'system_activity', 'system', ['system_id'],
                          ['id'])
def upgrade():
    drop_fk('recipe_task_comment', ['recipe_task_id'])
    op.alter_column('recipe_task_comment', 'recipe_task_id', nullable=False,
            existing_type=sa.Integer)
    op.create_foreign_key('recipe_task_comment_recipe_task_id_fk',
            'recipe_task_comment', 'recipe_task',
            ['recipe_task_id'], ['id'], onupdate='CASCADE', ondelete='CASCADE')
    drop_fk('recipe_task_comment', ['user_id'])
    op.drop_index('ix_recipe_task_comment_user_id', table_name='recipe_task_comment')
    op.alter_column('recipe_task_comment', 'user_id', nullable=False,
            existing_type=sa.Integer)
    op.create_foreign_key('recipe_task_comment_user_id_fk', 'recipe_task_comment',
            'tg_user', ['user_id'], ['user_id'], onupdate='CASCADE', ondelete='CASCADE')
    op.alter_column('recipe_task_comment', 'comment', nullable=False,
            type_=sa.Unicode(4000))
    op.alter_column('recipe_task_comment', 'created', nullable=False,
            existing_type=sa.DateTime)
def downgrade():
    drop_fk('recipe_task_comment', ['recipe_task_id'])
    op.alter_column('recipe_task_comment', 'recipe_task_id', nullable=True,
            existing_type=sa.Integer)
    op.create_foreign_key(None, 'recipe_task_comment', 'recipe_task',
            ['recipe_task_id'], ['id'])
    drop_fk('recipe_task_comment', ['user_id'])
    op.drop_index('recipe_task_comment_user_id_fk', table_name='recipe_task_comment')
    op.create_index('ix_recipe_task_comment_user_id', 'recipe_task_comment',
            ['user_id'])
    op.alter_column('recipe_task_comment', 'user_id', nullable=True,
            existing_type=sa.Integer)
    op.create_foreign_key(None, 'recipe_task_comment','tg_user', ['user_id'],
            ['user_id'])
    op.alter_column('recipe_task_comment', 'comment', nullable=True,
            type_=sa.UnicodeText())
    op.alter_column('recipe_task_comment', 'created', nullable=True,
            existing_type=sa.DateTime)
Exemple #7
0
def downgrade():
    op.add_column(
        'recipe',
        Column('rendered_kickstart_id',
               Integer,
               ForeignKey('rendered_kickstart.id',
                          name='recipe_rendered_kickstart_id_fk'),
               nullable=True))
    op.execute("""
        UPDATE recipe
        INNER JOIN installation ON installation.recipe_id = recipe.id
        SET recipe.rendered_kickstart_id = installation.rendered_kickstart_id
        """)

    op.execute("""
        ALTER TABLE recipe_resource
        ADD COLUMN rebooted DATETIME DEFAULT NULL,
        ADD COLUMN install_started DATETIME DEFAULT NULL,
        ADD COLUMN install_finished DATETIME DEFAULT NULL,
        ADD COLUMN postinstall_finished DATETIME DEFAULT NULL
        """)
    op.execute("""
        UPDATE recipe_resource
        INNER JOIN recipe ON recipe_resource.recipe_id = recipe.id
        INNER JOIN installation ON installation.recipe_id = recipe.id
        SET recipe_resource.rebooted = installation.rebooted,
            recipe_resource.install_started = installation.install_started,
            recipe_resource.install_finished = installation.install_finished,
            recipe_resource.postinstall_finished = installation.postinstall_finished
        """)

    op.add_column('virt_resource',
                  Column('kernel_options', Unicode(2048), nullable=True))
    op.execute("""
        UPDATE virt_resource
        INNER JOIN recipe_resource ON recipe_resource.id = virt_resource.id
        INNER JOIN recipe ON recipe_resource.recipe_id = recipe.id
        INNER JOIN installation ON installation.recipe_id = recipe.id
        SET virt_resource.kernel_options = installation.kernel_options
        """)

    drop_fk('command_queue', ['installation_id'])
    op.drop_column('command_queue', 'installation_id')
    op.drop_table('installation')
def downgrade():
    op.add_column('recipe', Column('rendered_kickstart_id', Integer,
            ForeignKey('rendered_kickstart.id', name='recipe_rendered_kickstart_id_fk'),
            nullable=True))
    op.execute("""
        UPDATE recipe
        INNER JOIN installation ON installation.recipe_id = recipe.id
        SET recipe.rendered_kickstart_id = installation.rendered_kickstart_id
        """)

    op.execute("""
        ALTER TABLE recipe_resource
        ADD COLUMN rebooted DATETIME DEFAULT NULL,
        ADD COLUMN install_started DATETIME DEFAULT NULL,
        ADD COLUMN install_finished DATETIME DEFAULT NULL,
        ADD COLUMN postinstall_finished DATETIME DEFAULT NULL
        """)
    op.execute("""
        UPDATE recipe_resource
        INNER JOIN recipe ON recipe_resource.recipe_id = recipe.id
        INNER JOIN installation ON installation.recipe_id = recipe.id
        SET recipe_resource.rebooted = installation.rebooted,
            recipe_resource.install_started = installation.install_started,
            recipe_resource.install_finished = installation.install_finished,
            recipe_resource.postinstall_finished = installation.postinstall_finished
        """)

    op.add_column('virt_resource', Column('kernel_options', Unicode(2048), nullable=True))
    op.execute("""
        UPDATE virt_resource
        INNER JOIN recipe_resource ON recipe_resource.id = virt_resource.id
        INNER JOIN recipe ON recipe_resource.recipe_id = recipe.id
        INNER JOIN installation ON installation.recipe_id = recipe.id
        SET virt_resource.kernel_options = installation.kernel_options
        """)

    drop_fk('command_queue', ['installation_id'])
    op.drop_column('command_queue', 'installation_id')
    op.drop_table('installation')
Exemple #9
0
def downgrade():
    drop_fk('recipe_task', ['task_id'])
    op.execute("""
        ALTER TABLE recipe_task
        DROP name,
        DROP version,
        DROP fetch_url,
        DROP fetch_subdir,
        MODIFY task_id INT NOT NULL
        """)
    op.create_foreign_key(None, 'recipe_task', 'task',
                ['task_id'], ['id'])
    op.execute("DELETE FROM system_access_policy_rule WHERE permission = 'view'")
    drop_enum_value('system_access_policy_rule', 'permission', 'view', nullable=False)
    op.drop_column('command_queue', 'quiescent_period')
    op.drop_index('status', 'command_queue')
    op.drop_column('power', 'power_quiescent_period')
    op.alter_column('tg_user', 'password', type_=sa.Unicode(40))
    op.execute("ALTER TABLE beaker_tag DROP PRIMARY KEY, ADD PRIMARY KEY (id, tag)")
    op.create_table('locked', sa.Column('id', sa.Integer(), primary_key=True))
    op.create_table('serial', sa.Column('id', sa.Integer(), primary_key=True))
    op.create_table('serial_type', sa.Column('id', sa.Integer(), primary_key=True))
    op.create_table('install', sa.Column('id', sa.Integer(), primary_key=True))
def upgrade():
    drop_fk("system_activity", ["system_id"])
    op.alter_column("system_activity", "system_id", existing_type=sa.Integer, nullable=False)
    op.create_foreign_key(None, "system_activity", "system", ["system_id"], ["id"])