diff --git a/butterfree/migrations/database_migration/cassandra_migration.py b/butterfree/migrations/database_migration/cassandra_migration.py index deef6cf5..9b804721 100644 --- a/butterfree/migrations/database_migration/cassandra_migration.py +++ b/butterfree/migrations/database_migration/cassandra_migration.py @@ -86,6 +86,7 @@ def _get_alter_column_type_query(self, column: Diff, table_name: str) -> str: Alter column type query. """ + def _get_alter_column_type_query(self, column: Diff, table_name: str) -> str: """Creates CQL statement to alter columns' types. In Cassandra 3.4.x to 3.11.x alter type is not allowed. @@ -102,15 +103,20 @@ def _get_alter_column_type_query(self, column: Diff, table_name: str) -> str: temp_column_name = f"{column.column}_temp" - add_temp_column_query = f"ALTER TABLE {table_name} ADD {temp_column_name} {column.value};" - copy_data_to_temp_query = f"UPDATE {table_name} SET {temp_column_name} = {column.column};" + add_temp_column_query = ( + f"ALTER TABLE {table_name} ADD {temp_column_name} {column.value};" + ) + copy_data_to_temp_query = ( + f"UPDATE {table_name} SET {temp_column_name} = {column.column};" + ) drop_old_column_query = f"ALTER TABLE {table_name} DROP {column.column};" - rename_temp_column_query = f"ALTER TABLE {table_name} RENAME {temp_column_name} TO {column.column};" + rename_temp_column_query = ( + f"ALTER TABLE {table_name} RENAME {temp_column_name} TO {column.column};" + ) return f"{add_temp_column_query} {copy_data_to_temp_query} {drop_old_column_query} {rename_temp_column_query};" - @staticmethod def _get_create_table_query(columns: List[Dict[str, Any]], table_name: str) -> str: """Creates CQL statement to create a table.