Ordinary database engine is deprecated but there is no simple mean to change database engine to Atomic for existing databases.

Possible options:
- ALTER DATABASE MODIFY ENGINE query.
- Flag that triggers migration at ClickHouse startup.

The latter should be easier to implement. 

{
    
    if (local_context->getClientInfo().query_kind != ClientInfo::QueryKind::INITIAL_QUERY)
        return {};
    const Settings & settings = local_context->getSettingsRef();
    if (settings.max_distributed_depth && local_context->getClientInfo().distributed_depth >= settings.max_distributed_depth)
        throw Exception("Maximum distributed depth exceeded", ErrorCodes::TOO_LARGE_DISTRIBUTED_DEPTH);
    auto & select = query.select->as<ASTSelectWithUnionQuery &>();
    StoragePtr src_storage;
    if (select.list_of_selects->children.size() == 1)
    {
        if (auto * select_query = select.list_of_selects->children.at(0)->as<ASTSelectQuery>())
        {
            JoinedTables joined_tables(Context::createCopy(local_context), *select_query);
            if (joined_tables.tablesCount() == 1)
            {
                src_storage = joined_tables.getLeftTableStorage();
            }
        }
    }
    if (!src_storage)
        return {};
    if (auto src_distributed = std::dynamic_pointer_cast<IStorageCluster>(src_storage))
    {
        return distributedWriteFromClusterStorage(src_distributed, query, local_context);
    }
    else if (local_context->getClientInfo().distributed_depth == 0)
    {