* [WIP] renamed current settings module and tables to have backup suffix * Created new settings table, schema, and context * Migrated from old settings module to new one * Removed settings backup modules * Added some tests and docs
32 lines
579 B
Elixir
32 lines
579 B
Elixir
defmodule Pinchflat.Settings.Setting do
|
|
@moduledoc """
|
|
The Setting schema.
|
|
"""
|
|
|
|
use Ecto.Schema
|
|
import Ecto.Changeset
|
|
|
|
@allowed_fields [
|
|
:onboarding,
|
|
:pro_enabled,
|
|
:yt_dlp_version
|
|
]
|
|
|
|
@required_fields ~w(
|
|
onboarding
|
|
pro_enabled
|
|
)a
|
|
|
|
schema "settings" do
|
|
field :onboarding, :boolean, default: true
|
|
field :pro_enabled, :boolean, default: false
|
|
field :yt_dlp_version, :string
|
|
end
|
|
|
|
@doc false
|
|
def changeset(setting, attrs) do
|
|
setting
|
|
|> cast(attrs, @allowed_fields)
|
|
|> validate_required(@required_fields)
|
|
end
|
|
end
|