Deployment and lifecycle management for Nix
0
fork

Configure Feed

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

server: link subscriptions and deployments

+14 -44
+1 -1
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 - many_to_many :seeds, Sower.Seed, join_through: Orchestration.SeedDeployment 14 + belongs_to :subscription, Orchestration.Subscription 15 15 16 16 many_to_many :store_paths, Sower.Nix.StorePath, 17 17 join_through: Orchestration.StorePathDeployment
-19
apps/sower/lib/sower/orchestration/seed_deployment.ex
··· 1 - defmodule Sower.Orchestration.SeedDeployment do 2 - use Sower.Schema 3 - import Ecto.Changeset 4 - 5 - schema "seeds_deployments" do 6 - field :seed_id, :id 7 - field :deployment_id, :id 8 - field :org_id, Ecto.UUID 9 - 10 - timestamps() 11 - end 12 - 13 - @doc false 14 - def changeset(seed_deployment, attrs) do 15 - seed_deployment 16 - |> cast(attrs, []) 17 - |> validate_required([]) 18 - end 19 - end
+6 -2
apps/sower/lib/sower/orchestration/subscription.ex
··· 1 1 defmodule Sower.Orchestration.Subscription do 2 - use Ecto.Schema 2 + use Sower.Schema 3 3 import Ecto.Changeset 4 4 5 5 @derive {Jason.Encoder, only: [:sid]} 6 6 @derive {Phoenix.Param, key: :sid} 7 + 8 + alias Sower.Orchestration.{Agent, Deployment} 7 9 8 10 schema "subscriptions" do 9 11 field :sid, Sower.Schema.Sid, autogenerate: true 10 12 field :org_id, Ecto.UUID 11 13 12 - belongs_to :agent, Sower.Orchestration.Agent 14 + belongs_to :agent, Agent 13 15 belongs_to :seed, Sower.Seed 16 + 17 + has_many :deployments, Deployment 14 18 15 19 timestamps(type: :utc_datetime) 16 20 end
-3
apps/sower/lib/sower/seed.ex
··· 20 20 21 21 many_to_many :store_paths, Nix.StorePath, join_through: Sower.SeedStorePath 22 22 23 - many_to_many :deployments, Orchestration.Deployment, 24 - join_through: Orchestration.SeedDeployment 25 - 26 23 timestamps() 27 24 end 28 25
+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 + 9 11 add :deployed_at, :utc_datetime 10 12 11 13 timestamps()
-18
apps/sower/priv/repo/migrations/20250531134025_create_seeds_deployments.exs
··· 1 - defmodule Sower.Repo.Migrations.CreateSeedsDeployments do 2 - use Ecto.Migration 3 - 4 - def change do 5 - create table(:seeds_deployments) do 6 - add :seed_id, references(:seeds, on_delete: :nothing) 7 - add :deployment_id, references(:deployments, on_delete: :nothing) 8 - add :org_id, references(:organizations, column: :org_id, type: :uuid), null: false 9 - 10 - timestamps() 11 - end 12 - 13 - create index(:seeds_deployments, [:seed_id]) 14 - create index(:seeds_deployments, [:deployment_id]) 15 - create index(:seeds_deployments, [:org_id]) 16 - create unique_index(:seeds_deployments, [:seed_id, :deployment_id]) 17 - end 18 - end
apps/sower/priv/repo/migrations/20250616035226_create_agents.exs apps/sower/priv/repo/migrations/20250531120000_create_agents.exs
+5 -1
apps/sower/priv/repo/migrations/20250629035109_drop_client.exs
··· 1 1 defmodule Sower.Repo.Migrations.DropClient do 2 2 use Ecto.Migration 3 3 4 - def change do 4 + def up do 5 5 drop table(:clients) 6 + end 7 + 8 + def down do 9 + create table(:clients) 6 10 end 7 11 end
apps/sower/priv/repo/migrations/20250706214320_create_subscriptions.exs apps/sower/priv/repo/migrations/20250531130000_create_subscriptions.exs