diff --git a/server/lib/ingest/destinations.ex b/server/lib/ingest/destinations.ex index cb33618..dadcf93 100644 --- a/server/lib/ingest/destinations.ex +++ b/server/lib/ingest/destinations.ex @@ -302,13 +302,36 @@ defmodule Ingest.Destinations do from(d in Destination, where: fragment( - "searchable @@ websearch_to_tsquery(?)", + "searchable @@ to_tsquery(concat(regexp_replace(trim(?), '\W+', ':* & '), ':*'))", ^search_term ) and d.id not in ^Enum.map(exclude, fn d -> d.id end), order_by: { :desc, fragment( - "ts_rank_cd(searchable, websearch_to_tsquery(?), 4)", + "ts_rank_cd(searchable, to_tsquery(concat(regexp_replace(trim(?), '\W+', ':* & '), ':*')), 4)", + ^search_term + ) + } + ) + + Repo.all(query) + end + + @defaults %{exclude: []} + def search_own(search_term, %User{} = user, opts \\ []) do + %{exclude: exclude} = Enum.into(opts, @defaults) + + query = + from(d in Destination, + where: + fragment( + "searchable @@ to_tsquery(concat(regexp_replace(trim(?), '\W+', ':* & '), ':*'))", + ^search_term + ) and d.id not in ^Enum.map(exclude, fn d -> d.id end) and d.inserted_by == ^user.id, + order_by: { + :desc, + fragment( + "ts_rank_cd(searchable, to_tsquery(concat(regexp_replace(trim(?), '\W+', ':* & '), ':*')), 4)", ^search_term ) } diff --git a/server/lib/ingest/destinations/destination.ex b/server/lib/ingest/destinations/destination.ex index d9f894f..d713db3 100644 --- a/server/lib/ingest/destinations/destination.ex +++ b/server/lib/ingest/destinations/destination.ex @@ -82,7 +82,7 @@ defmodule Ingest.Destinations.S3Config do field :path, Ingest.Encrypted.Binary field :final_path, Ingest.Encrypted.Binary field :ssl, :boolean, default: true - field :integrated_metadata, :boolean, default: true + field :integrated_metadata, :boolean, default: false end @doc false @@ -118,7 +118,7 @@ defmodule Ingest.Destinations.AzureConfig do field :container, Ingest.Encrypted.Binary field :path, Ingest.Encrypted.Binary field :final_path, Ingest.Encrypted.Binary - field :integrated_metadata, :boolean, default: true + field :integrated_metadata, :boolean, default: false end @doc false @@ -153,7 +153,7 @@ defmodule Ingest.Destinations.LakeFSConfig do field :repository, Ingest.Encrypted.Binary field :port, :integer, default: nil field :ssl, :boolean, default: true - field :integrated_metadata, :boolean, default: true + field :integrated_metadata, :boolean, default: false end @doc false diff --git a/server/lib/ingest/requests.ex b/server/lib/ingest/requests.ex index b541198..dac0347 100644 --- a/server/lib/ingest/requests.ex +++ b/server/lib/ingest/requests.ex @@ -182,7 +182,7 @@ defmodule Ingest.Requests do do: Repo.get!(Request, id) |> Repo.preload(:templates) - |> Repo.preload(:project) + |> Repo.preload(project: [:templates, :destinations]) |> Repo.preload(:destinations) @doc """ @@ -329,13 +329,35 @@ defmodule Ingest.Requests do from t in Template, where: fragment( - "searchable @@ websearch_to_tsquery(?)", + "searchable @@ to_tsquery(concat(regexp_replace(trim(?), '\W+', ':* & '), ':*'))", ^search_term ) and t.id not in ^Enum.map(exclude, fn d -> d.id end), order_by: { :desc, fragment( - "ts_rank_cd(searchable, websearch_to_tsquery(?), 4)", + "ts_rank_cd(searchable, to_tsquery(concat(regexp_replace(trim(?), '\W+', ':* & '), ':*')), 4)", + ^search_term + ) + } + + Repo.all(query) + end + + @defaults %{exclude: []} + def search_own_templates(search_term, %User{} = user, opts \\ []) do + %{exclude: exclude} = Enum.into(opts, @defaults) + + query = + from t in Template, + where: + fragment( + "searchable @@ to_tsquery(concat(regexp_replace(trim(?), '\W+', ':* & '), ':*'))", + ^search_term + ) and t.id not in ^Enum.map(exclude, fn d -> d.id end) and t.inserted_by == ^user.id, + order_by: { + :desc, + fragment( + "ts_rank_cd(searchable, to_tsquery(concat(regexp_replace(trim(?), '\W+', ':* & '), ':*')), 4)", ^search_term ) } @@ -350,13 +372,13 @@ defmodule Ingest.Requests do on: p.id == r.project_id, where: fragment( - "p1.searchable @@ websearch_to_tsquery(?)", + "p1.searchable @@ to_tsquery(concat(regexp_replace(trim(?), '\W+', ':* & '), ':*'))", ^search_term - ), + ) and r.status == :published, order_by: { :desc, fragment( - "ts_rank_cd(p1.searchable, websearch_to_tsquery(?), 4)", + "ts_rank_cd(p1.searchable, to_tsquery(concat(regexp_replace(trim(?), '\W+', ':* & '), ':*')), 4)", ^search_term ) } diff --git a/server/lib/ingest_web/components_live/destination_form.ex b/server/lib/ingest_web/components_live/destination_form.ex index da9d867..c4d8773 100644 --- a/server/lib/ingest_web/components_live/destination_form.ex +++ b/server/lib/ingest_web/components_live/destination_form.ex @@ -298,7 +298,7 @@ defmodule IngestWeb.LiveComponents.DestinationForm do <.input type="text" field={config[:base_url]} />
- Leave blank to use the service's default option. + Leave blank to use the service's default option. Do not include trailing slashes or "https://".
<.label for="status-select"> diff --git a/server/lib/ingest_web/components_live/metadata_entry_form.ex b/server/lib/ingest_web/components_live/metadata_entry_form.ex index e24d98e..3e8c9e3 100644 --- a/server/lib/ingest_web/components_live/metadata_entry_form.ex +++ b/server/lib/ingest_web/components_live/metadata_entry_form.ex @@ -60,6 +60,7 @@ defmodule IngestWeb.LiveComponents.MetadataEntryForm do <.input label={field.label} name={field.label} + required={field.required} field={@metadata_form[field.label]} type={Atom.to_string(field.type)} options={ diff --git a/server/lib/ingest_web/components_live/search_form.ex b/server/lib/ingest_web/components_live/search_form.ex index bcc65dd..eb8ba5d 100644 --- a/server/lib/ingest_web/components_live/search_form.ex +++ b/server/lib/ingest_web/components_live/search_form.ex @@ -115,7 +115,9 @@ defmodule IngestWeb.LiveComponents.SearchForm do socket |> assign( :results, - Ingest.Requests.search_templates(value, exclude: Enum.flat_map(excludes, fn d -> d end)) + Ingest.Requests.search_own_templates(value, socket.assigns.current_user, + exclude: Enum.flat_map(excludes, fn d -> d end) + ) )} end @@ -126,7 +128,9 @@ defmodule IngestWeb.LiveComponents.SearchForm do socket |> assign( :results, - Ingest.Destinations.search(value, exclude: Enum.flat_map(excludes, fn d -> d end)) + Ingest.Destinations.search_own(value, socket.assigns.current_user, + exclude: Enum.flat_map(excludes, fn d -> d end) + ) )} end end diff --git a/server/lib/ingest_web/live/dashboard_live/metadata_entry_live.ex b/server/lib/ingest_web/live/dashboard_live/metadata_entry_live.ex index 6399ca5..7bbccb9 100644 --- a/server/lib/ingest_web/live/dashboard_live/metadata_entry_live.ex +++ b/server/lib/ingest_web/live/dashboard_live/metadata_entry_live.ex @@ -250,7 +250,7 @@ defmodule IngestWeb.MetadataEntryLive do upload = Uploads.get_upload!(upload_id) classifications_allowed = - request.destinations + (request.destinations ++ request.project.destinations) |> Enum.map(fn d -> d.classifications_allowed end) |> List.flatten() |> Enum.uniq() @@ -258,7 +258,7 @@ defmodule IngestWeb.MetadataEntryLive do {:noreply, socket |> assign(:classifications_allowed, classifications_allowed) - |> assign(:templates, request.templates) + |> assign(:templates, request.templates ++ request.project.templates) |> assign(:upload, upload) |> allow_upload(:files, auto_upload: true, @@ -273,7 +273,7 @@ defmodule IngestWeb.MetadataEntryLive do original_filename: upload.filename, filename: "#{entry.client_name}", user: socket.assigns.current_user, - destinations: request.destinations, + destinations: request.destinations ++ request.project.destinations, request: request} end ) diff --git a/server/lib/ingest_web/live/dashboard_live/request_show_live.ex b/server/lib/ingest_web/live/dashboard_live/request_show_live.ex index 208f380..fe21a23 100644 --- a/server/lib/ingest_web/live/dashboard_live/request_show_live.ex +++ b/server/lib/ingest_web/live/dashboard_live/request_show_live.ex @@ -14,7 +14,8 @@ defmodule IngestWeb.RequestShowLive do+ Show this field only for the provided file extensions. +
Comma-seperated values. Example: .csv,.pdf,.html - Leave blank for all file types
@@ -409,7 +412,7 @@ defmodule IngestWeb.TemplateBuilderLive do case Ingest.Requests.update_template(socket.assigns.template, %{fields: fields}) do {:ok, _template} -> socket - |> push_patch( + |> push_navigate( to: ~p"/dashboard/templates/#{socket.assigns.template.id}/fields/#{socket.assigns.field.id}" ) diff --git a/server/lib/ingest_web/live/dashboard_live/upload_show_live.ex b/server/lib/ingest_web/live/dashboard_live/upload_show_live.ex index 0fd7058..71db114 100644 --- a/server/lib/ingest_web/live/dashboard_live/upload_show_live.ex +++ b/server/lib/ingest_web/live/dashboard_live/upload_show_live.ex @@ -132,7 +132,7 @@ defmodule IngestWeb.UploadShowLive do request = Requests.get_request!(id) classifications_allowed = - request.destinations + (request.destinations ++ request.project.destinations) |> Enum.map(fn d -> d.classifications_allowed end) |> List.flatten() |> Enum.uniq() @@ -159,7 +159,7 @@ defmodule IngestWeb.UploadShowLive do {Ingest.Uploaders.MultiDestinationWriter, filename: "#{entry.client_name}", user: socket.assigns.current_user, - destinations: request.destinations, + destinations: request.destinations ++ request.project.destinations, request: request} end ) diff --git a/server/mix.lock b/server/mix.lock index 7524030..ee08473 100644 --- a/server/mix.lock +++ b/server/mix.lock @@ -21,18 +21,18 @@ "elixir_make": {:hex, :elixir_make, "0.8.4", "4960a03ce79081dee8fe119d80ad372c4e7badb84c493cc75983f9d3bc8bde0f", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.0", [hex: :certifi, repo: "hexpm", optional: true]}], "hexpm", "6e7f1d619b5f61dfabd0a20aa268e575572b542ac31723293a4c1a567d5ef040"}, "elixir_uuid": {:hex, :elixir_uuid, "1.2.1", "dce506597acb7e6b0daeaff52ff6a9043f5919a4c3315abb4143f0b00378c097", [:mix], [], "hexpm", "f7eba2ea6c3555cea09706492716b0d87397b88946e6380898c2889d68585752"}, "erlazure": {:git, "https://github.inl.gov/Alexandria/erlazure", "d2864d0ebae05ffbd51c3399b5341768eb404f11", []}, - "error_tracker": {:hex, :error_tracker, "0.2.1", "cfa9b95a8b1d8531b1648ea5f8f4f773a24b729e336f0aae9ec3f3b4663aa41c", [:mix], [{:ecto, "~> 3.11", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_sql, "~> 3.0", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:ecto_sqlite3, ">= 0.0.0", [hex: :ecto_sqlite3, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:phoenix_ecto, "~> 4.6", [hex: :phoenix_ecto, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.19 or ~> 1.0", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:postgrex, ">= 0.0.0", [hex: :postgrex, repo: "hexpm", optional: true]}], "hexpm", "f9033eaa1bba6e9727033c51a7ffdc2ea769e76e091d7f3eff618d449e05324e"}, + "error_tracker": {:hex, :error_tracker, "0.2.2", "7635f5ed6016df10d8e63348375acb2ca411e2f6f9703ee90cc2d4262af5faec", [:mix], [{:ecto, "~> 3.11", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_sql, "~> 3.0", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:ecto_sqlite3, ">= 0.0.0", [hex: :ecto_sqlite3, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:phoenix_ecto, "~> 4.6", [hex: :phoenix_ecto, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.19 or ~> 1.0", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:postgrex, ">= 0.0.0", [hex: :postgrex, repo: "hexpm", optional: true]}], "hexpm", "b975978f64d27373d3486d7de477a699e735f8c0b1c74a7370ecb80e7ae97903"}, "esbuild": {:hex, :esbuild, "0.8.1", "0cbf919f0eccb136d2eeef0df49c4acf55336de864e63594adcea3814f3edf41", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "25fc876a67c13cb0a776e7b5d7974851556baeda2085296c14ab48555ea7560f"}, "eternal": {:hex, :eternal, "1.2.2", "d1641c86368de99375b98d183042dd6c2b234262b8d08dfd72b9eeaafc2a1abd", [:mix], [], "hexpm", "2c9fe32b9c3726703ba5e1d43a1d255a4f3f2d8f8f9bc19f094c7cb1a7a9e782"}, "ex_aws": {:hex, :ex_aws, "2.5.4", "86c5bb870a49e0ab6f5aa5dd58cf505f09d2624ebe17530db3c1b61c88a673af", [:mix], [{:configparser_ex, "~> 4.0", [hex: :configparser_ex, repo: "hexpm", optional: true]}, {:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: true]}, {:jsx, "~> 2.8 or ~> 3.0", [hex: :jsx, repo: "hexpm", optional: true]}, {:mime, "~> 1.2 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:sweet_xml, "~> 0.7", [hex: :sweet_xml, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "e82bd0091bb9a5bb190139599f922ff3fc7aebcca4374d65c99c4e23aa6d1625"}, "ex_aws_s3": {:hex, :ex_aws_s3, "2.5.3", "422468e5c3e1a4da5298e66c3468b465cfd354b842e512cb1f6fbbe4e2f5bdaf", [:mix], [{:ex_aws, "~> 2.0", [hex: :ex_aws, repo: "hexpm", optional: false]}, {:sweet_xml, ">= 0.0.0", [hex: :sweet_xml, repo: "hexpm", optional: true]}], "hexpm", "4f09dd372cc386550e484808c5ac5027766c8d0cd8271ccc578b82ee6ef4f3b8"}, "ex_microsoft_azure_storage": {:hex, :ex_microsoft_azure_storage, "1.1.1", "90240289ffab4265a4486e8f7cf6968c5d326c53067980e8652e582c4d4f174c", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: true]}, {:poison, ">= 1.0.0", [hex: :poison, repo: "hexpm", optional: true]}, {:sweet_xml, "~> 0.7", [hex: :sweet_xml, repo: "hexpm", optional: false]}, {:tesla, "~> 1.4", [hex: :tesla, repo: "hexpm", optional: false]}, {:timex, "~> 3.7", [hex: :timex, repo: "hexpm", optional: false]}, {:xml_builder, "~> 2.2", [hex: :xml_builder, repo: "hexpm", optional: false]}], "hexpm", "deda52a44d12837efc8858e802f3618a76c2f1301239ae86e1adb1d1e16a6ce7"}, "expo": {:hex, :expo, "1.0.0", "647639267e088717232f4d4451526e7a9de31a3402af7fcbda09b27e9a10395a", [:mix], [], "hexpm", "18d2093d344d97678e8a331ca0391e85d29816f9664a25653fd7e6166827827c"}, - "file_system": {:hex, :file_system, "1.0.0", "b689cc7dcee665f774de94b5a832e578bd7963c8e637ef940cd44327db7de2cd", [:mix], [], "hexpm", "6752092d66aec5a10e662aefeed8ddb9531d79db0bc145bb8c40325ca1d8536d"}, + "file_system": {:hex, :file_system, "1.0.1", "79e8ceaddb0416f8b8cd02a0127bdbababe7bf4a23d2a395b983c1f8b3f73edd", [:mix], [], "hexpm", "4414d1f38863ddf9120720cd976fce5bdde8e91d8283353f0e31850fa89feb9e"}, "finch": {:hex, :finch, "0.18.0", "944ac7d34d0bd2ac8998f79f7a811b21d87d911e77a786bc5810adb75632ada4", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.3", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 0.2.6 or ~> 1.0", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "69f5045b042e531e53edc2574f15e25e735b522c37e2ddb766e15b979e03aa65"}, "floki": {:hex, :floki, "0.36.2", "a7da0193538c93f937714a6704369711998a51a6164a222d710ebd54020aa7a3", [:mix], [], "hexpm", "a8766c0bc92f074e5cb36c4f9961982eda84c5d2b8e979ca67f5c268ec8ed580"}, "gen_smtp": {:hex, :gen_smtp, "1.2.0", "9cfc75c72a8821588b9b9fe947ae5ab2aed95a052b81237e0928633a13276fd3", [:rebar3], [{:ranch, ">= 1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "5ee0375680bca8f20c4d85f58c2894441443a743355430ff33a783fe03296779"}, - "gettext": {:hex, :gettext, "0.25.0", "98a95a862a94e2d55d24520dd79256a15c87ea75b49673a2e2f206e6ebc42e5d", [:mix], [{:expo, "~> 0.5.1 or ~> 1.0", [hex: :expo, repo: "hexpm", optional: false]}], "hexpm", "38e5d754e66af37980a94fb93bb20dcde1d2361f664b0a19f01e87296634051f"}, + "gettext": {:hex, :gettext, "0.26.1", "38e14ea5dcf962d1fc9f361b63ea07c0ce715a8ef1f9e82d3dfb8e67e0416715", [:mix], [{:expo, "~> 0.5.1 or ~> 1.0", [hex: :expo, repo: "hexpm", optional: false]}], "hexpm", "01ce56f188b9dc28780a52783d6529ad2bc7124f9744e571e1ee4ea88bf08734"}, "hackney": {:hex, :hackney, "1.20.1", "8d97aec62ddddd757d128bfd1df6c5861093419f8f7a4223823537bad5d064e2", [:rebar3], [{:certifi, "~> 2.12.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~> 6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~> 1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~> 1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.4.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~> 1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "fe9094e5f1a2a2c0a7d10918fee36bfec0ec2a979994cff8cfe8058cd9af38e3"}, "hpax": {:hex, :hpax, "1.0.0", "28dcf54509fe2152a3d040e4e3df5b265dcb6cb532029ecbacf4ce52caea3fd2", [:mix], [], "hexpm", "7f1314731d711e2ca5fdc7fd361296593fc2542570b3105595bb0bc6d0fad601"}, "httpoison": {:hex, :httpoison, "1.8.2", "9eb9c63ae289296a544842ef816a85d881d4a31f518a0fec089aaa744beae290", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "2bb350d26972e30c96e2ca74a1aaf8293d61d0742ff17f01e0279fef11599921"}, @@ -49,7 +49,7 @@ "nimble_options": {:hex, :nimble_options, "1.1.1", "e3a492d54d85fc3fd7c5baf411d9d2852922f66e69476317787a7b2bb000a61b", [:mix], [], "hexpm", "821b2470ca9442c4b6984882fe9bb0389371b8ddec4d45a9504f00a66f650b44"}, "nimble_ownership": {:hex, :nimble_ownership, "0.3.1", "99d5244672fafdfac89bfad3d3ab8f0d367603ce1dc4855f86a1c75008bce56f", [:mix], [], "hexpm", "4bf510adedff0449a1d6e200e43e57a814794c8b5b6439071274d248d272a549"}, "nimble_pool": {:hex, :nimble_pool, "1.1.0", "bf9c29fbdcba3564a8b800d1eeb5a3c58f36e1e11d7b7fb2e084a643f645f06b", [:mix], [], "hexpm", "af2e4e6b34197db81f7aad230c1118eac993acc0dae6bc83bac0126d4ae0813a"}, - "oban": {:hex, :oban, "2.18.1", "604663121017de4f61a44908a63e7fc431201fa21dcb858ef6686ed46a2e32bd", [:mix], [{:ecto_sql, "~> 3.10", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:ecto_sqlite3, "~> 0.9", [hex: :ecto_sqlite3, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.16", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "f998b755a856757c86761bc718b84ce0474b1b68abb9248f690e761a90b9186a"}, + "oban": {:hex, :oban, "2.18.2", "583e78965ee15263ac968e38c983bad169ae55eadaa8e1e39912562badff93ba", [:mix], [{:ecto_sql, "~> 3.10", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:ecto_sqlite3, "~> 0.9", [hex: :ecto_sqlite3, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.16", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "9dd25fd35883a91ed995e9fe516e479344d3a8623dfe2b8c3fc8e5be0228ec3a"}, "oidcc": {:git, "https://github.com/erlef/oidcc.git", "9bfc39905ecfca0f0b90efa153ce6cbd0f2a0454", [tag: "v3.1.1"]}, "openid_connect": {:hex, :openid_connect, "0.2.2", "c05055363330deab39ffd89e609db6b37752f255a93802006d83b45596189c0b", [:mix], [{:httpoison, "~> 1.2", [hex: :httpoison, repo: "hexpm", optional: false]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: false]}, {:jose, "~> 1.8", [hex: :jose, repo: "hexpm", optional: false]}], "hexpm", "735769b6d592124b58edd0582554ce638524c0214cd783d8903d33357d74cc13"}, "parse_trans": {:hex, :parse_trans, "3.4.1", "6e6aa8167cb44cc8f39441d05193be6e6f4e7c2946cb2759f015f8c56b76e5ff", [:rebar3], [], "hexpm", "620a406ce75dada827b82e453c19cf06776be266f5a67cff34e1ef2cbb60e49a"}, @@ -72,7 +72,7 @@ "sleeplocks": {:hex, :sleeplocks, "1.1.3", "96a86460cc33b435c7310dbd27ec82ca2c1f24ae38e34f8edde97f756503441a", [:rebar3], [], "hexpm", "d3b3958552e6eb16f463921e70ae7c767519ef8f5be46d7696cc1ed649421321"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"}, "sweet_xml": {:hex, :sweet_xml, "0.7.4", "a8b7e1ce7ecd775c7e8a65d501bc2cd933bff3a9c41ab763f5105688ef485d08", [:mix], [], "hexpm", "e7c4b0bdbf460c928234951def54fe87edf1a170f6896675443279e2dbeba167"}, - "swoosh": {:hex, :swoosh, "1.16.10", "04be6e2eb1a31aa0aa21a731175c81cc3998189456a92daf13d44a5c754afcf5", [:mix], [{:bandit, ">= 1.0.0", [hex: :bandit, repo: "hexpm", optional: true]}, {:cowboy, "~> 1.1 or ~> 2.4", [hex: :cowboy, repo: "hexpm", optional: true]}, {:ex_aws, "~> 2.1", [hex: :ex_aws, repo: "hexpm", optional: true]}, {:finch, "~> 0.6", [hex: :finch, repo: "hexpm", optional: true]}, {:gen_smtp, "~> 0.13 or ~> 1.0", [hex: :gen_smtp, repo: "hexpm", optional: true]}, {:hackney, "~> 1.9", [hex: :hackney, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mail, "~> 0.2", [hex: :mail, repo: "hexpm", optional: true]}, {:mime, "~> 1.1 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mua, "~> 0.2.3", [hex: :mua, repo: "hexpm", optional: true]}, {:multipart, "~> 0.4", [hex: :multipart, repo: "hexpm", optional: true]}, {:plug, "~> 1.9", [hex: :plug, repo: "hexpm", optional: true]}, {:plug_cowboy, ">= 1.0.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:req, "~> 0.5 or ~> 1.0", [hex: :req, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.2 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "756be04db173c0cbe318f1dfe2bcc88aa63aed78cf5a4b02b61b36ee11fc716a"}, + "swoosh": {:hex, :swoosh, "1.16.12", "cbb24ad512f2f7f24c7a469661c188a00a8c2cd64e0ab54acd1520f132092dfd", [:mix], [{:bandit, ">= 1.0.0", [hex: :bandit, repo: "hexpm", optional: true]}, {:cowboy, "~> 1.1 or ~> 2.4", [hex: :cowboy, repo: "hexpm", optional: true]}, {:ex_aws, "~> 2.1", [hex: :ex_aws, repo: "hexpm", optional: true]}, {:finch, "~> 0.6", [hex: :finch, repo: "hexpm", optional: true]}, {:gen_smtp, "~> 0.13 or ~> 1.0", [hex: :gen_smtp, repo: "hexpm", optional: true]}, {:hackney, "~> 1.9", [hex: :hackney, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mail, "~> 0.2", [hex: :mail, repo: "hexpm", optional: true]}, {:mime, "~> 1.1 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mua, "~> 0.2.3", [hex: :mua, repo: "hexpm", optional: true]}, {:multipart, "~> 0.4", [hex: :multipart, repo: "hexpm", optional: true]}, {:plug, "~> 1.9", [hex: :plug, repo: "hexpm", optional: true]}, {:plug_cowboy, ">= 1.0.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:req, "~> 0.5 or ~> 1.0", [hex: :req, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.2 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "0e262df1ae510d59eeaaa3db42189a2aa1b3746f73771eb2616fc3f7ee63cc20"}, "table_rex": {:hex, :table_rex, "4.0.0", "3c613a68ebdc6d4d1e731bc973c233500974ec3993c99fcdabb210407b90959b", [:mix], [], "hexpm", "c35c4d5612ca49ebb0344ea10387da4d2afe278387d4019e4d8111e815df8f55"}, "tailwind": {:hex, :tailwind, "0.2.3", "277f08145d407de49650d0a4685dc062174bdd1ae7731c5f1da86163a24dfcdb", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}], "hexpm", "8e45e7a34a676a7747d04f7913a96c770c85e6be810a1d7f91e713d3a3655b5d"}, "telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"}, diff --git a/server/priv/repo/migrations/20240822144741_fix_constraints.exs b/server/priv/repo/migrations/20240822144741_fix_constraints.exs new file mode 100644 index 0000000..170cff0 --- /dev/null +++ b/server/priv/repo/migrations/20240822144741_fix_constraints.exs @@ -0,0 +1,83 @@ +defmodule Ingest.Repo.Migrations.FixConstraints do + use Ecto.Migration + + def change do + alter table(:uploads) do + modify :request_id, references(:requests, on_delete: :delete_all, type: :binary_id), + from: references(:requests, on_delete: :nothing, type: :binary_id) + + modify :uploaded_by, references(:users, on_delete: :nilify_all, type: :binary_id), + from: references(:requests, on_delete: :nothing, type: :binary_id) + end + + alter table(:request_destinations) do + modify :request_id, references(:requests, on_delete: :delete_all, type: :binary_id), + from: references(:requests, on_delete: :nothing, type: :binary_id) + + modify :destination_id, references(:destinations, on_delete: :delete_all, type: :binary_id), + from: references(:destinations, on_delete: :nothing, type: :binary_id) + end + + alter table(:request_members) do + modify :request_id, references(:requests, on_delete: :delete_all, type: :binary_id) + end + + alter table(:request_templates) do + modify :request_id, references(:requests, on_delete: :delete_all, type: :binary_id), + from: references(:requests, on_delete: :nothing, type: :binary_id) + + modify :template_id, references(:templates, on_delete: :delete_all, type: :binary_id), + from: references(:templates, on_delete: :nothing, type: :binary_id) + end + + alter table(:request_uploads) do + modify :request_id, references(:requests, on_delete: :delete_all, type: :binary_id), + from: references(:requests, on_delete: :nothing, type: :binary_id) + + modify :upload_id, references(:uploads, on_delete: :delete_all, type: :binary_id), + from: references(:uploads, on_delete: :nothing, type: :binary_id) + end + + alter table(:project_templates) do + modify :project_id, references(:projects, on_delete: :delete_all, type: :binary_id), + from: references(:projects, on_delete: :nothing, type: :binary_id) + + modify :template_id, references(:templates, on_delete: :delete_all, type: :binary_id), + from: references(:templates, on_delete: :nothing, type: :binary_id) + end + + alter table(:project_members) do + modify :project_id, references(:projects, on_delete: :delete_all, type: :binary_id), + from: references(:projects, on_delete: :nothing, type: :binary_id) + + modify :member_id, references(:users, on_delete: :delete_all, type: :binary_id), + from: references(:users, on_delete: :nothing, type: :binary_id) + end + + alter table(:project_invites) do + modify :project_id, references(:projects, on_delete: :delete_all, type: :binary_id), + from: references(:projects, on_delete: :nothing, type: :binary_id) + end + + alter table(:project_destinations) do + modify :project_id, references(:projects, on_delete: :delete_all, type: :binary_id), + from: references(:projects, on_delete: :nothing, type: :binary_id) + + modify :destination_id, references(:destinations, on_delete: :delete_all, type: :binary_id), + from: references(:destinations, on_delete: :nothing, type: :binary_id) + end + + alter table(:metadata) do + modify :upload_id, references(:uploads, on_delete: :delete_all, type: :binary_id), + from: references(:uploads, on_delete: :nothing, type: :binary_id) + end + + alter table(:upload_destination_paths) do + modify :upload_id, references(:uploads, on_delete: :delete_all, type: :binary_id), + from: references(:uploads, on_delete: :nothing, type: :binary_id) + + modify :destination_id, references(:destinations, on_delete: :delete_all, type: :binary_id), + from: references(:destinations, on_delete: :nothing, type: :binary_id) + end + end +end