create channel<->note join table
This commit is contained in:
parent
58d11699f3
commit
4d20f5c4d0
|
@ -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
|
|
@ -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
|
Loading…
Reference in New Issue