From 6c5b4bb5864d7e3f1ff18322a2a204108653fb04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Fri, 29 Sep 2023 18:51:56 +0700 Subject: [PATCH] Add migration for new file system attributes compatible with Livebook main --- lib/livebook/migration.ex | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/livebook/migration.ex b/lib/livebook/migration.ex index e28aa0b2d..0dd5ff14a 100644 --- a/lib/livebook/migration.ex +++ b/lib/livebook/migration.ex @@ -9,7 +9,9 @@ defmodule Livebook.Migration do move_app_secrets_to_personal_hub() add_personal_hub_secret_key() update_file_systems_to_deterministic_ids() + ensure_new_file_system_attributes() move_default_file_system_id_to_default_dir() + :ok end defp delete_local_host_hub() do @@ -96,6 +98,26 @@ defmodule Livebook.Migration do end end + defp ensure_new_file_system_attributes() do + # Note that this is already handled by update_file_systems_to_deterministic_ids/0, + # we add this migration so it also applies to people using Livebook main + + # TODO: remove on Livebook v0.12 + + for attrs <- Livebook.Storage.all(:file_systems) do + # Ensure new file system fields + new_attrs = %{ + hub_id: Livebook.Hubs.Personal.id(), + external_id: nil, + region: Livebook.FileSystem.S3.region_from_uri(attrs.bucket_url) + } + + attrs = Map.merge(new_attrs, attrs) + + Livebook.Storage.insert(:file_systems, attrs.id, Map.to_list(attrs)) + end + end + defp move_default_file_system_id_to_default_dir() do # Convert default_file_system_id to default_dir # TODO: remove on Livebook v0.12