parent
							
								
									2c7bb30996
								
							
						
					
					
						commit
						b4c8a43c37
					
				@ -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
 | 
				
			||||
					Loading…
					
					
				
		Reference in new issue