feat: first entities in database

This commit is contained in:
2026-04-23 12:21:13 +02:00
parent 28141deb8b
commit 13ac446793
10 changed files with 568 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
defmodule BDS.Projects.Project do
@moduledoc false
use Ecto.Schema
import Ecto.Changeset
@primary_key {:id, :string, autogenerate: false}
@foreign_key_type :string
schema "projects" do
field :name, :string
field :slug, :string
field :description, :string
field :data_path, :string
field :created_at, :integer
field :updated_at, :integer
field :is_active, :boolean, default: false
has_many :posts, BDS.Posts.Post, foreign_key: :project_id
end
def changeset(project, attrs) do
project
|> cast(attrs, [:id, :name, :slug, :description, :data_path, :created_at, :updated_at, :is_active],
empty_values: [nil]
)
|> validate_required([:id, :name, :slug, :created_at, :updated_at, :is_active])
|> unique_constraint(:slug)
end
end