-
-
Save Narven/eedffd4e84a88d02d1ce378563f97990 to your computer and use it in GitHub Desktop.
Revisions
-
stevedomin revised this gist
Mar 1, 2016 . 3 changed files with 14 additions and 24 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ defmodule MyBlog.Repo.Migrations.CreatePost do use Ecto.Migration def change do create table(:posts, primary_key: false) do add :id, :uuid, primary_key: true add :body, :string add :word_count, :integer timestamps end end end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,23 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ defmodule MyBlog.Post do use MyBlog.Web, :model @primary_key {:id, :binary_id, autogenerate: true} schema "posts" do field :body, :string -
stevedomin renamed this gist
May 7, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
stevedomin renamed this gist
May 7, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
stevedomin created this gist
May 7, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ defmodule MyBlog.Repo.Migrations.CreatePost do use Ecto.Migration def up do # This should go in a separate migration if you're using UUIDs across your app execute "CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\"" create table(:posts, primary_key: false) do add :id, :uuid, primary_key: true, default: fragment("uuid_generate_v1()") add :body, :string add :word_count, :integer timestamps end end def down do execute "DROP EXTENSION IF EXISTS \"uuid-ossp\"" drop table(:posts) end end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ defmodule MyBlog.Post do use MyBlog.Web, :model @primary_key {:id, Ecto.UUID, [read_after_writes: true]} schema "posts" do field :body, :string field :word_count, :integer timestamps end @required_fields ~w(body word_count) @optional_fields ~w() @doc """ Creates a changeset based on the `model` and `params`. If `params` are nil, an invalid changeset is returned with no validation performed. """ def changeset(model, params \\ nil) do model |> cast(params, @required_fields, @optional_fields) end end