Skip to content

Commit

Permalink
Change jitp>product relation to has_many
Browse files Browse the repository at this point in the history
Actual relation between jitp and product is has_one. There is no valid
reason for limiting JITP enabled certificate to one per product.

This commit:
* updates Ecto schema
* adds migration to remove unique_index on jitp.product_id

Fixes nerves-hub#871
  • Loading branch information
Jean Parpaillon committed Dec 21, 2022
1 parent c28b9bd commit 6b8c55b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ defmodule NervesHubWebCore.Products.Product do
has_many(:firmwares, Firmware)
has_many(:product_users, ProductUser)
has_many(:users, through: [:product_users, :user])
has_one(:jitp, CACertificate.JITP)
has_many(:jitp, CACertificate.JITP)

belongs_to(:org, Org, where: [deleted_at: nil])

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
defmodule NervesHubWebCore.Repo.Migrations.RemoveJitpProductUniqueness do
use Ecto.Migration

def change do
drop unique_index(:jitp, [:product_id])
end
end

0 comments on commit 6b8c55b

Please sign in to comment.