defmodule DaProductApp.SBOM.Component do use DaProductApp.Schema import Ecto.Changeset import Logger @primary_key {:id, :id, autogenerate: true} # Changed from binary_id to standard auto-incrementing id @foreign_key_type :id # Changed to match the new primary key type schema "components" do field :version, :string field :component_name, :string field :supplier_type, :string field :supplier_name, :string field :relationship, :string field :checksum_type, :string field :checksum_algorithm, :string field :checksum_value, :string field :user_id, :integer field :application_id, :integer field :organization_id, :integer timestamps(type: :utc_datetime) end @spec changeset( {map(), %{ optional(atom()) => atom() | {:array | :assoc | :embed | :in | :map | :parameterized | :supertype | :try, any()} }} | %{ :__struct__ => atom() | %{:__changeset__ => any(), optional(any()) => any()}, optional(atom()) => any() }, :invalid | %{optional(:__struct__) => none(), optional(atom() | binary()) => any()} ) :: Ecto.Changeset.t() @doc false def changeset(component, attrs) do Logger.debug("Component changeset inside db: #{inspect(attrs)}") # Correct usage component |> cast(attrs, [ :component_name, :version, :supplier_type, :supplier_name, :relationship, :checksum_type, :checksum_algorithm, :checksum_value, :user_id, :application_id, :organization_id ]) |> validate_required([ :component_name, :version, :supplier_type, :supplier_name, :relationship, :checksum_type, :checksum_algorithm, :checksum_value, :user_id, :application_id, :organization_id ]) end end