diff --git a/coriolis/db/sqlalchemy/migrate_repo/versions/020_rename_tables.py b/coriolis/db/sqlalchemy/migrate_repo/versions/020_rename_tables.py index cc5e259e..a6bed3b3 100644 --- a/coriolis/db/sqlalchemy/migrate_repo/versions/020_rename_tables.py +++ b/coriolis/db/sqlalchemy/migrate_repo/versions/020_rename_tables.py @@ -8,10 +8,22 @@ def upgrade(migrate_engine): replica = sqlalchemy.Table('replica', meta, autoload=True) replica.rename('transfer') - migration = sqlalchemy.Table('migration', meta, autoload=True) - migration.rename('deployment') - migration.c.replica_id.alter(name='transfer_id', nullable=False) - migration.c.replication_count.drop() + deployment = sqlalchemy.Table( + 'deployment', meta, + sqlalchemy.Column("id", sqlalchemy.String(36), + sqlalchemy.ForeignKey( + 'base_transfer_action.base_id'), + primary_key=True), + sqlalchemy.Column("transfer_id", sqlalchemy.String(36), + sqlalchemy.ForeignKey('transfer.id'), + nullable=False), + mysql_engine="InnoDB", + mysql_charset="utf8") + try: + deployment.create() + except Exception: + deployment.drop() + raise replica_schedule = sqlalchemy.Table( 'replica_schedules', meta, autoload=True) @@ -25,6 +37,14 @@ def upgrade(migrate_engine): conn.execute( 'UPDATE base_transfer_action SET type = "transfer" ' 'WHERE type = "replica";') + conn.execute('UPDATE tasks_execution SET type = "transfer_execution"' + 'WHERE type = "replica_execution"') conn.execute( - 'UPDATE base_transfer_action SET type = "deployment" ' - 'WHERE type = "migration";') + 'UPDATE tasks_execution SET type = "transfer_disks_delete"' + 'WHERE type = "replica_disks_delete"') + conn.execute( + 'UPDATE tasks_execution SET type = "deployment"' + 'WHERE type = "replica_deploy"') + conn.execute( + 'UPDATE tasks_execution SET type = "transfer_update"' + 'WHERE type = "replica_update"') diff --git a/coriolis/db/sqlalchemy/models.py b/coriolis/db/sqlalchemy/models.py index 638d13d9..dd90b63a 100644 --- a/coriolis/db/sqlalchemy/models.py +++ b/coriolis/db/sqlalchemy/models.py @@ -361,8 +361,6 @@ class Deployment(BaseTransferAction): transfer = orm.relationship( Transfer, backref=orm.backref("deployments"), foreign_keys=[transfer_id]) - shutdown_instances = sqlalchemy.Column( - sqlalchemy.Boolean, nullable=False, default=False) __mapper_args__ = { 'polymorphic_identity': 'deployment', @@ -377,7 +375,6 @@ def to_dict(self, include_task_info=True, include_tasks=True): "id": self.id, "transfer_id": self.transfer_id, "transfer_scenario_type": self.transfer.scenario, - "shutdown_instances": self.shutdown_instances, }) return base diff --git a/coriolis/tests/db/sqlalchemy/test_models.py b/coriolis/tests/db/sqlalchemy/test_models.py index b2209159..fa110244 100644 --- a/coriolis/tests/db/sqlalchemy/test_models.py +++ b/coriolis/tests/db/sqlalchemy/test_models.py @@ -344,11 +344,9 @@ def test_to_dict(self): deployment.id = mock.sentinel.id deployment.transfer_id = transfer.id deployment.transfer = transfer - deployment.shutdown_instances = mock.sentinel.shutdown_instances expected_result = { "id": mock.sentinel.id, "transfer_id": mock.sentinel.transfer_id, - "shutdown_instances": mock.sentinel.shutdown_instances, "transfer_scenario_type": transfer.scenario, }