Deployment and lifecycle management for Nix
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

server: a deployment has many subscriptions

+43 -20
+3 -2
apps/sower/lib/sower/orchestration/deployment.ex
··· 11 11 field :sid, Sower.Schema.Sid, autogenerate: true 12 12 field :org_id, Ecto.UUID 13 13 14 - belongs_to :subscription, Orchestration.Subscription 14 + many_to_many :subscriptions, Sower.Orchestration.Subscription, 15 + join_through: Orchestration.SubscriptionDeployment 15 16 16 17 many_to_many :store_paths, Sower.Nix.StorePath, 17 18 join_through: Orchestration.StorePathDeployment ··· 26 27 deployment 27 28 |> cast(attrs, [:deployed_at]) 28 29 |> put_assoc(:store_paths, attrs.store_paths) 29 - |> put_assoc(:subscription, attrs.subscription) 30 + |> put_assoc(:subscriptions, attrs.subscriptions) 30 31 |> validate_required([]) 31 32 end 32 33 end
+18
apps/sower/lib/sower/orchestration/subscription_deployment.ex
··· 1 + defmodule Sower.Orchestration.SubscriptionDeployment do 2 + use Sower.Schema 3 + import Ecto.Changeset 4 + 5 + schema "subscriptions_deployments" do 6 + field :subscription_id, :id 7 + field :deployment_id, :id 8 + 9 + timestamps() 10 + end 11 + 12 + @doc false 13 + def changeset(subscription_deployment, attrs) do 14 + subscription_deployment 15 + |> cast(attrs, []) 16 + |> validate_required([:subscription_id, :deployment_id]) 17 + end 18 + end
+22 -2
apps/sower/priv/repo/migrations/20250531133248_create_deployments.exs
··· 6 6 add :sid, :string, null: false 7 7 add :org_id, references(:organizations, column: :org_id, type: :uuid), null: false 8 8 9 - add :subscription_id, references(:subscriptions, on_delete: :nothing), null: false 10 - 11 9 add :deployed_at, :utc_datetime 12 10 13 11 timestamps() ··· 15 13 16 14 create index(:deployments, [:org_id]) 17 15 create unique_index(:deployments, :sid) 16 + 17 + create table(:store_paths_deployments) do 18 + add :store_path_id, references(:store_paths, on_delete: :nothing), null: false 19 + add :deployment_id, references(:deployments, on_delete: :nothing), null: false 20 + 21 + timestamps() 22 + end 23 + 24 + create index(:store_paths_deployments, [:store_path_id]) 25 + create index(:store_paths_deployments, [:deployment_id]) 26 + create unique_index(:store_paths_deployments, [:store_path_id, :deployment_id]) 27 + 28 + create table(:subscriptions_deployments) do 29 + add :subscription_id, references(:subscriptions, on_delete: :nothing), null: false 30 + add :deployment_id, references(:deployments, on_delete: :nothing), null: false 31 + 32 + timestamps() 33 + end 34 + 35 + create index(:subscriptions_deployments, [:subscription_id]) 36 + create index(:subscriptions_deployments, [:deployment_id]) 37 + create unique_index(:subscriptions_deployments, [:subscription_id, :deployment_id]) 18 38 end 19 39 end
-16
apps/sower/priv/repo/migrations/20250531134253_create_store_paths_deployments.exs
··· 1 - defmodule Sower.Repo.Migrations.CreateStorePathsDeployments do 2 - use Ecto.Migration 3 - 4 - def change do 5 - create table(:store_paths_deployments) do 6 - add :store_path_id, references(:store_paths, on_delete: :nothing), null: false 7 - add :deployment_id, references(:deployments, on_delete: :nothing), null: false 8 - 9 - timestamps() 10 - end 11 - 12 - create index(:store_paths_deployments, [:store_path_id]) 13 - create index(:store_paths_deployments, [:deployment_id]) 14 - create unique_index(:store_paths_deployments, [:store_path_id, :deployment_id]) 15 - end 16 - end