diff --git a/ironic/cmd/dbsync.py b/ironic/cmd/dbsync.py index b5b3dc27f9..154cbcae00 100644 --- a/ironic/cmd/dbsync.py +++ b/ironic/cmd/dbsync.py @@ -36,9 +36,6 @@ class DBCommand(object): def upgrade(self): migration.upgrade(CONF.command.revision) - def downgrade(self): - migration.downgrade(CONF.command.revision) - def revision(self): migration.revision(CONF.command.message, CONF.command.autogenerate) @@ -63,14 +60,6 @@ def add_command_parsers(subparsers): parser.set_defaults(func=command_object.upgrade) parser.add_argument('--revision', nargs='?') - parser = subparsers.add_parser( - 'downgrade', - help=_("Downgrade the database schema to the oldest revision. " - "While optional, one should generally use --revision to " - "specify the alembic revision string to downgrade to.")) - parser.set_defaults(func=command_object.downgrade) - parser.add_argument('--revision', nargs='?') - parser = subparsers.add_parser('stamp') parser.add_argument('--revision', nargs='?') parser.set_defaults(func=command_object.stamp) diff --git a/ironic/db/migration.py b/ironic/db/migration.py index 2cc6e5bda4..7e0fd18e3a 100644 --- a/ironic/db/migration.py +++ b/ironic/db/migration.py @@ -36,10 +36,6 @@ def upgrade(version=None): return get_backend().upgrade(version) -def downgrade(version=None): - return get_backend().downgrade(version) - - def version(): return get_backend().version() diff --git a/ironic/db/sqlalchemy/alembic/versions/1e1d5ace7dc6_add_inspection_started_at_and_.py b/ironic/db/sqlalchemy/alembic/versions/1e1d5ace7dc6_add_inspection_started_at_and_.py index 58d8954d33..1bf191246a 100644 --- a/ironic/db/sqlalchemy/alembic/versions/1e1d5ace7dc6_add_inspection_started_at_and_.py +++ b/ironic/db/sqlalchemy/alembic/versions/1e1d5ace7dc6_add_inspection_started_at_and_.py @@ -33,8 +33,3 @@ def upgrade(): op.add_column('nodes', sa.Column('inspection_finished_at', sa.DateTime(), nullable=True)) - - -def downgrade(): - op.drop_column('nodes', 'inspection_started_at') - op.drop_column('nodes', 'inspection_finished_at') diff --git a/ironic/db/sqlalchemy/alembic/versions/21b331f883ef_add_provision_updated_at.py b/ironic/db/sqlalchemy/alembic/versions/21b331f883ef_add_provision_updated_at.py index 12eb08fee6..6074113d11 100644 --- a/ironic/db/sqlalchemy/alembic/versions/21b331f883ef_add_provision_updated_at.py +++ b/ironic/db/sqlalchemy/alembic/versions/21b331f883ef_add_provision_updated_at.py @@ -29,7 +29,3 @@ import sqlalchemy as sa def upgrade(): op.add_column('nodes', sa.Column('provision_updated_at', sa.DateTime(), nullable=True)) - - -def downgrade(): - op.drop_column('nodes', 'provision_updated_at') diff --git a/ironic/db/sqlalchemy/alembic/versions/242cc6a923b3_add_node_maintenance_reason.py b/ironic/db/sqlalchemy/alembic/versions/242cc6a923b3_add_node_maintenance_reason.py index 57d1987852..0d7b718221 100644 --- a/ironic/db/sqlalchemy/alembic/versions/242cc6a923b3_add_node_maintenance_reason.py +++ b/ironic/db/sqlalchemy/alembic/versions/242cc6a923b3_add_node_maintenance_reason.py @@ -30,7 +30,3 @@ def upgrade(): op.add_column('nodes', sa.Column('maintenance_reason', sa.Text(), nullable=True)) - - -def downgrade(): - op.drop_column('nodes', 'maintenance_reason') diff --git a/ironic/db/sqlalchemy/alembic/versions/2581ebaf0cb2_initial_migration.py b/ironic/db/sqlalchemy/alembic/versions/2581ebaf0cb2_initial_migration.py index 868b8db677..61cdb2f7d9 100644 --- a/ironic/db/sqlalchemy/alembic/versions/2581ebaf0cb2_initial_migration.py +++ b/ironic/db/sqlalchemy/alembic/versions/2581ebaf0cb2_initial_migration.py @@ -99,8 +99,3 @@ def upgrade(): mysql_DEFAULT_CHARSET='UTF8' ) # end Alembic commands - - -def downgrade(): - raise NotImplementedError(('Downgrade from initial migration is' - ' unsupported.')) diff --git a/ironic/db/sqlalchemy/alembic/versions/2fb93ffd2af1_increase_node_name_length.py b/ironic/db/sqlalchemy/alembic/versions/2fb93ffd2af1_increase_node_name_length.py index d73e2291f6..f45b309c57 100644 --- a/ironic/db/sqlalchemy/alembic/versions/2fb93ffd2af1_increase_node_name_length.py +++ b/ironic/db/sqlalchemy/alembic/versions/2fb93ffd2af1_increase_node_name_length.py @@ -33,10 +33,3 @@ def upgrade(): existing_type=mysql.VARCHAR(length=63), type_=sa.String(length=255), existing_nullable=True) - - -def downgrade(): - op.alter_column('nodes', 'name', - existing_type=sa.String(length=255), - type_=mysql.VARCHAR(length=63), - existing_nullable=True) diff --git a/ironic/db/sqlalchemy/alembic/versions/31baaf680d2b_add_node_instance_info.py b/ironic/db/sqlalchemy/alembic/versions/31baaf680d2b_add_node_instance_info.py index 1e7b5d4936..6dd869b0b1 100644 --- a/ironic/db/sqlalchemy/alembic/versions/31baaf680d2b_add_node_instance_info.py +++ b/ironic/db/sqlalchemy/alembic/versions/31baaf680d2b_add_node_instance_info.py @@ -32,9 +32,3 @@ def upgrade(): sa.Text(), nullable=True)) # end Alembic commands - - -def downgrade(): - # commands auto generated by Alembic - please adjust - op.drop_column('nodes', 'instance_info') - # end Alembic commands diff --git a/ironic/db/sqlalchemy/alembic/versions/3ae36a5f5131_add_logical_name.py b/ironic/db/sqlalchemy/alembic/versions/3ae36a5f5131_add_logical_name.py index 58d58bd404..456ab65c69 100644 --- a/ironic/db/sqlalchemy/alembic/versions/3ae36a5f5131_add_logical_name.py +++ b/ironic/db/sqlalchemy/alembic/versions/3ae36a5f5131_add_logical_name.py @@ -30,8 +30,3 @@ def upgrade(): op.add_column('nodes', sa.Column('name', sa.String(length=63), nullable=True)) op.create_unique_constraint('uniq_nodes0name', 'nodes', ['name']) - - -def downgrade(): - op.drop_constraint('uniq_nodes0name', 'nodes', type_='unique') - op.drop_column('nodes', 'name') diff --git a/ironic/db/sqlalchemy/alembic/versions/3bea56f25597_add_unique_constraint_to_instance_uuid.py b/ironic/db/sqlalchemy/alembic/versions/3bea56f25597_add_unique_constraint_to_instance_uuid.py index 6f92deda0d..48cb3a3b27 100644 --- a/ironic/db/sqlalchemy/alembic/versions/3bea56f25597_add_unique_constraint_to_instance_uuid.py +++ b/ironic/db/sqlalchemy/alembic/versions/3bea56f25597_add_unique_constraint_to_instance_uuid.py @@ -32,8 +32,3 @@ def upgrade(): op.create_unique_constraint("uniq_nodes0instance_uuid", "nodes", ["instance_uuid"]) op.drop_index('node_instance_uuid', 'nodes') - - -def downgrade(): - op.drop_constraint("uniq_nodes0instance_uuid", "nodes", type_='unique') - op.create_index('node_instance_uuid', 'nodes', ['instance_uuid']) diff --git a/ironic/db/sqlalchemy/alembic/versions/3cb628139ea4_nodes_add_console_enabled.py b/ironic/db/sqlalchemy/alembic/versions/3cb628139ea4_nodes_add_console_enabled.py index fb698f14b1..19f2ca8492 100644 --- a/ironic/db/sqlalchemy/alembic/versions/3cb628139ea4_nodes_add_console_enabled.py +++ b/ironic/db/sqlalchemy/alembic/versions/3cb628139ea4_nodes_add_console_enabled.py @@ -28,7 +28,3 @@ import sqlalchemy as sa def upgrade(): op.add_column('nodes', sa.Column('console_enabled', sa.Boolean)) - - -def downgrade(): - op.drop_column('nodes', 'console_enabled') diff --git a/ironic/db/sqlalchemy/alembic/versions/487deb87cc9d_add_conductor_affinity_and_online.py b/ironic/db/sqlalchemy/alembic/versions/487deb87cc9d_add_conductor_affinity_and_online.py index e02b450c33..f455300ade 100644 --- a/ironic/db/sqlalchemy/alembic/versions/487deb87cc9d_add_conductor_affinity_and_online.py +++ b/ironic/db/sqlalchemy/alembic/versions/487deb87cc9d_add_conductor_affinity_and_online.py @@ -36,10 +36,3 @@ def upgrade(): sa.ForeignKey('conductors.id', name='nodes_conductor_affinity_fk'), nullable=True)) - - -def downgrade(): - op.drop_constraint('nodes_conductor_affinity_fk', 'nodes', - type_='foreignkey') - op.drop_column('nodes', 'conductor_affinity') - op.drop_column('conductors', 'online') diff --git a/ironic/db/sqlalchemy/alembic/versions/48d6c242bb9b_add_node_tags.py b/ironic/db/sqlalchemy/alembic/versions/48d6c242bb9b_add_node_tags.py index e57d98cf63..61c2ea31b3 100644 --- a/ironic/db/sqlalchemy/alembic/versions/48d6c242bb9b_add_node_tags.py +++ b/ironic/db/sqlalchemy/alembic/versions/48d6c242bb9b_add_node_tags.py @@ -40,7 +40,3 @@ def upgrade(): mysql_DEFAULT_CHARSET='UTF8' ) op.create_index('node_tags_idx', 'node_tags', ['tag'], unique=False) - - -def downgrade(): - op.drop_table('node_tags') diff --git a/ironic/db/sqlalchemy/alembic/versions/4f399b21ae71_add_node_clean_step.py b/ironic/db/sqlalchemy/alembic/versions/4f399b21ae71_add_node_clean_step.py index a8c57983de..f685e74301 100644 --- a/ironic/db/sqlalchemy/alembic/versions/4f399b21ae71_add_node_clean_step.py +++ b/ironic/db/sqlalchemy/alembic/versions/4f399b21ae71_add_node_clean_step.py @@ -29,7 +29,3 @@ import sqlalchemy as sa def upgrade(): op.add_column('nodes', sa.Column('clean_step', sa.Text(), nullable=True)) - - -def downgrade(): - op.drop_column('nodes', 'clean_step') diff --git a/ironic/db/sqlalchemy/alembic/versions/516faf1bb9b1_resizing_column_nodes_driver.py b/ironic/db/sqlalchemy/alembic/versions/516faf1bb9b1_resizing_column_nodes_driver.py index 9358afd7f8..72260ca1f1 100644 --- a/ironic/db/sqlalchemy/alembic/versions/516faf1bb9b1_resizing_column_nodes_driver.py +++ b/ironic/db/sqlalchemy/alembic/versions/516faf1bb9b1_resizing_column_nodes_driver.py @@ -30,7 +30,3 @@ def upgrade(): op.alter_column('nodes', 'driver', existing_type=sa.String(length=15), type_=sa.String(length=255)) - - -def downgrade(): - pass diff --git a/ironic/db/sqlalchemy/alembic/versions/5674c57409b9_replace_nostate_with_available.py b/ironic/db/sqlalchemy/alembic/versions/5674c57409b9_replace_nostate_with_available.py index 38c2343e23..ab133c9008 100644 --- a/ironic/db/sqlalchemy/alembic/versions/5674c57409b9_replace_nostate_with_available.py +++ b/ironic/db/sqlalchemy/alembic/versions/5674c57409b9_replace_nostate_with_available.py @@ -43,10 +43,3 @@ def upgrade(): node.update().where( node.c.provision_state == null()).values( {'provision_state': op.inline_literal(AVAILABLE)})) - - -def downgrade(): - op.execute( - node.update().where( - node.c.provision_state == op.inline_literal(AVAILABLE)).values( - {'provision_state': None})) diff --git a/ironic/db/sqlalchemy/alembic/versions/789acc877671_add_raid_config.py b/ironic/db/sqlalchemy/alembic/versions/789acc877671_add_raid_config.py index d83382b1f1..ec751b0bd2 100644 --- a/ironic/db/sqlalchemy/alembic/versions/789acc877671_add_raid_config.py +++ b/ironic/db/sqlalchemy/alembic/versions/789acc877671_add_raid_config.py @@ -31,8 +31,3 @@ def upgrade(): nullable=True)) op.add_column('nodes', sa.Column('target_raid_config', sa.Text(), nullable=True)) - - -def downgrade(): - op.drop_column('nodes', 'raid_config') - op.drop_column('nodes', 'target_raid_config') diff --git a/ironic/db/sqlalchemy/alembic/versions/bb59b63f55a_add_node_driver_internal_info.py b/ironic/db/sqlalchemy/alembic/versions/bb59b63f55a_add_node_driver_internal_info.py index 46b1aa70ac..2bcd11c9c8 100644 --- a/ironic/db/sqlalchemy/alembic/versions/bb59b63f55a_add_node_driver_internal_info.py +++ b/ironic/db/sqlalchemy/alembic/versions/bb59b63f55a_add_node_driver_internal_info.py @@ -30,7 +30,3 @@ def upgrade(): op.add_column('nodes', sa.Column('driver_internal_info', sa.Text(), nullable=True)) - - -def downgrade(): - op.drop_column('nodes', 'driver_internal_info') diff --git a/ironic/tests/unit/db/sqlalchemy/test_migrations.py b/ironic/tests/unit/db/sqlalchemy/test_migrations.py index 20b8e01a0c..e46a9672b8 100644 --- a/ironic/tests/unit/db/sqlalchemy/test_migrations.py +++ b/ironic/tests/unit/db/sqlalchemy/test_migrations.py @@ -98,7 +98,7 @@ def patch_with_engine(engine): class WalkVersionsMixin(object): - def _walk_versions(self, engine=None, alembic_cfg=None, downgrade=True): + def _walk_versions(self, engine=None, alembic_cfg=None): # Determine latest version script from the repo, then # upgrade from 1 through to the latest, with no data # in the databases. This just checks that the schema itself @@ -117,31 +117,6 @@ class WalkVersionsMixin(object): self._migrate_up(engine, alembic_cfg, version.revision, with_data=True) - if downgrade: - for version in versions: - self._migrate_down(engine, alembic_cfg, version.revision) - - def _migrate_down(self, engine, config, version, with_data=False): - try: - self.migration_api.downgrade(version, config=config) - except NotImplementedError: - # NOTE(sirp): some migrations, namely release-level - # migrations, don't support a downgrade. - return False - - self.assertEqual(version, self.migration_api.version(config)) - - # NOTE(sirp): `version` is what we're downgrading to (i.e. the 'target' - # version). So if we have any downgrade checks, they need to be run for - # the previous (higher numbered) migration. - if with_data: - post_downgrade = getattr( - self, "_post_downgrade_%s" % (version), None) - if post_downgrade: - post_downgrade(engine) - - return True - def _migrate_up(self, engine, config, version, with_data=False): """migrate up to a new version of the db. @@ -201,29 +176,9 @@ class TestWalkVersions(base.TestCase, WalkVersionsMixin): self._pre_upgrade_141.assert_called_with(self.engine) self._check_141.assert_called_with(self.engine, test_value) - def test_migrate_down(self): - self.migration_api.version.return_value = '42' - - self.assertTrue(self._migrate_down(self.engine, self.config, '42')) - self.migration_api.version.assert_called_with(self.config) - - def test_migrate_down_not_implemented(self): - self.migration_api.downgrade.side_effect = NotImplementedError - self.assertFalse(self._migrate_down(self.engine, self.config, '42')) - - def test_migrate_down_with_data(self): - self._post_downgrade_043 = mock.MagicMock() - self.migration_api.version.return_value = '043' - - self._migrate_down(self.engine, self.config, '043', True) - - self._post_downgrade_043.assert_called_with(self.engine) - @mock.patch.object(script, 'ScriptDirectory') @mock.patch.object(WalkVersionsMixin, '_migrate_up') - @mock.patch.object(WalkVersionsMixin, '_migrate_down') - def test_walk_versions_all_default(self, _migrate_up, _migrate_down, - script_directory): + def test_walk_versions_all_default(self, _migrate_up, script_directory): fc = script_directory.from_config() fc.walk_revisions.return_value = self.versions self.migration_api.version.return_value = None @@ -236,20 +191,14 @@ class TestWalkVersions(base.TestCase, WalkVersionsMixin): with_data=True) for v in reversed(self.versions)] self.assertEqual(self._migrate_up.call_args_list, upgraded) - downgraded = [mock.call(self.engine, self.config, v.revision) - for v in self.versions] - self.assertEqual(self._migrate_down.call_args_list, downgraded) - @mock.patch.object(script, 'ScriptDirectory') @mock.patch.object(WalkVersionsMixin, '_migrate_up') - @mock.patch.object(WalkVersionsMixin, '_migrate_down') - def test_walk_versions_all_false(self, _migrate_up, _migrate_down, - script_directory): + def test_walk_versions_all_false(self, _migrate_up, script_directory): fc = script_directory.from_config() fc.walk_revisions.return_value = self.versions self.migration_api.version.return_value = None - self._walk_versions(self.engine, self.config, downgrade=False) + self._walk_versions(self.engine, self.config) upgraded = [mock.call(self.engine, self.config, v.revision, with_data=True) for v in reversed(self.versions)] @@ -264,7 +213,7 @@ class MigrationCheckersMixin(object): self.migration_api = migration def test_walk_versions(self): - self._walk_versions(self.engine, self.config, downgrade=False) + self._walk_versions(self.engine, self.config) def test_connect_fail(self): """Test that we can trigger a database connection failure diff --git a/releasenotes/notes/no-downward-sql-migration-52279e875cd8b7a3.yaml b/releasenotes/notes/no-downward-sql-migration-52279e875cd8b7a3.yaml new file mode 100644 index 0000000000..788f6dd07c --- /dev/null +++ b/releasenotes/notes/no-downward-sql-migration-52279e875cd8b7a3.yaml @@ -0,0 +1,5 @@ +--- +features: + - Database migrations downgrade support was removed. More info about + database migration/rollback could be found here + http://docs.openstack.org/openstack-ops/content/ops_upgrades-roll-back.html