Many-to-many between performers and performances.
This commit is contained in:
18
lib/runosaari/core/performer_performance.ex
Normal file
18
lib/runosaari/core/performer_performance.ex
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
defmodule Runosaari.Core.PerformerPerformance do
|
||||||
|
use Ecto.Schema
|
||||||
|
import Ecto.Changeset
|
||||||
|
|
||||||
|
schema "performer_performance" do
|
||||||
|
field :performer_id, :id
|
||||||
|
field :performance_id, :id
|
||||||
|
|
||||||
|
timestamps()
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc false
|
||||||
|
def changeset(performer_performance, attrs) do
|
||||||
|
performer_performance
|
||||||
|
|> cast(attrs, [])
|
||||||
|
|> validate_required([])
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
defmodule Runosaari.Repo.Migrations.CreatePerformerPerformance do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def change do
|
||||||
|
create table(:performer_performance, primary_key: false) do
|
||||||
|
add :performer_id, references(:performers, on_delete: :nothing), primary_key: true
|
||||||
|
add :performance_id, references(:performances, on_delete: :nothing), primary_key: true
|
||||||
|
end
|
||||||
|
|
||||||
|
create index(:performer_performance, [:performer_id])
|
||||||
|
create index(:performer_performance, [:performance_id])
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user