add default channel

This commit is contained in:
Inhji 2023-03-23 08:18:05 +01:00
parent d088ad71f8
commit 2befd9e2a3
2 changed files with 12 additions and 1 deletions

View file

@ -14,6 +14,7 @@ defmodule Chiya.Site.Setting do
field :user_agent, :string, default: "Chiya/0.x +https://inhji.de" field :user_agent, :string, default: "Chiya/0.x +https://inhji.de"
belongs_to :home_channel, Chiya.Channels.Channel belongs_to :home_channel, Chiya.Channels.Channel
belongs_to :default_channel, Chiya.Channels.Channel
timestamps() timestamps()
end end
@ -28,7 +29,8 @@ defmodule Chiya.Site.Setting do
:user_agent, :user_agent,
:custom_css, :custom_css,
:custom_html, :custom_html,
:home_channel_id :home_channel_id,
:default_channel_id
]) ])
|> validate_required([:title, :subtitle, :theme, :user_agent]) |> validate_required([:title, :subtitle, :theme, :user_agent])
end end

View file

@ -0,0 +1,9 @@
defmodule Chiya.Repo.Migrations.AddDefaultChannelSetting do
use Ecto.Migration
def change do
alter table(:settings) do
add :default_channel_id, references(:channels, on_delete: :nothing)
end
end
end