Add the Link model.

This commit is contained in:
2023-07-04 21:50:30 +03:00
parent 2c7bb30996
commit b4c8a43c37
2 changed files with 30 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
defmodule LinkShortener.Link do
use Ecto.Schema
import Ecto.Changeset
schema "links" do
field :name, :string
field :url, :string
timestamps()
end
@doc false
def changeset(link, attrs) do
link
|> cast(attrs, [:name, :url])
|> validate_required([:name, :url])
end
end
@@ -0,0 +1,12 @@
defmodule LinkShortener.Repo.Migrations.CreateLinks do
use Ecto.Migration
def change do
create table(:links) do
add :name, :string
add :url, :string
timestamps()
end
end
end