create channel<->note join table

This commit is contained in:
Inhji 2023-03-05 18:14:06 +01:00
parent 58d11699f3
commit 4d20f5c4d0
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,19 @@
defmodule Chiya.Channels.ChannelNote do
use Ecto.Schema
import Ecto.Changeset
schema "channels_notes" do
field :channel, :id
field :note, :id
timestamps()
end
@doc false
def changeset(channel_note, attrs) do
channel_note
|> cast(attrs, [])
|> validate_required([])
end
end

View File

@ -0,0 +1,15 @@
defmodule Chiya.Repo.Migrations.CreateChannelsNotes do
use Ecto.Migration
def change do
create table(:channels_notes) do
add :channel, references(:channels, on_delete: :nothing)
add :note, references(:notes, on_delete: :nothing)
timestamps()
end
create index(:channels_notes, [:channel])
create index(:channels_notes, [:note])
end
end