Skip to content

Commit dfd50af

Browse files
authored
Use typed schemas (#42)
1 parent 8a03e89 commit dfd50af

File tree

9 files changed

+16
-14
lines changed

9 files changed

+16
-14
lines changed

lib/swapi/schemas/film.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ defmodule SWAPI.Schemas.Film do
33
Film schema
44
"""
55

6-
use Ecto.Schema
6+
use TypedEctoSchema
77
import Ecto.Changeset
88

99
alias SWAPI.Schemas.Person
@@ -15,7 +15,7 @@ defmodule SWAPI.Schemas.Film do
1515
@required_fields [:title, :episode_id, :opening_crawl, :director, :producer, :release_date]
1616
@optional_fields [:id, :created, :edited]
1717

18-
schema "films" do
18+
typed_schema "films" do
1919
field :title, :string
2020
field :episode_id, :integer
2121
field :opening_crawl, :string

lib/swapi/schemas/person.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ defmodule SWAPI.Schemas.Person do
33
Person schema
44
"""
55

6-
use Ecto.Schema
6+
use TypedEctoSchema
77
import Ecto.Changeset
88

99
alias SWAPI.Schemas.Film
@@ -24,7 +24,7 @@ defmodule SWAPI.Schemas.Person do
2424
]
2525
@optional_fields [:id, :homeworld_id, :created, :edited]
2626

27-
schema "people" do
27+
typed_schema "people" do
2828
field :name, :string
2929
field :birth_year, :string
3030
field :eye_color, :string

lib/swapi/schemas/planet.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ defmodule SWAPI.Schemas.Planet do
33
Planet schema
44
"""
55

6-
use Ecto.Schema
6+
use TypedEctoSchema
77
import Ecto.Changeset
88

99
alias SWAPI.Schemas.Film
@@ -22,7 +22,7 @@ defmodule SWAPI.Schemas.Planet do
2222
]
2323
@optional_fields [:id, :created, :edited]
2424

25-
schema "planets" do
25+
typed_schema "planets" do
2626
field :name, :string
2727
field :diameter, :string
2828
field :rotation_period, :string

lib/swapi/schemas/species.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ defmodule SWAPI.Schemas.Species do
33
Species schema
44
"""
55

6-
use Ecto.Schema
6+
use TypedEctoSchema
77
import Ecto.Changeset
88

99
alias SWAPI.Schemas.Film
@@ -23,7 +23,7 @@ defmodule SWAPI.Schemas.Species do
2323
]
2424
@optional_fields [:id, :homeworld_id, :created, :edited]
2525

26-
schema "species" do
26+
typed_schema "species" do
2727
field :name, :string
2828
field :classification, :string
2929
field :designation, :string

lib/swapi/schemas/starship.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ defmodule SWAPI.Schemas.Starship do
33
Starship schema
44
"""
55

6-
use Ecto.Schema
6+
use TypedEctoSchema
77
import Ecto.Changeset
88

99
alias SWAPI.Schemas.Film
@@ -15,7 +15,7 @@ defmodule SWAPI.Schemas.Starship do
1515

1616
@primary_key false
1717

18-
schema "starships" do
18+
typed_schema "starships" do
1919
belongs_to :transport, Transport, foreign_key: :id, primary_key: true, on_replace: :update
2020

2121
field :starship_class, :string

lib/swapi/schemas/transport.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ defmodule SWAPI.Schemas.Transport do
33
Transport schema
44
"""
55

6-
use Ecto.Schema
6+
use TypedEctoSchema
77
import Ecto.Changeset
88

99
@required_fields [
@@ -20,7 +20,7 @@ defmodule SWAPI.Schemas.Transport do
2020
]
2121
@optional_fields [:id, :created, :edited]
2222

23-
schema "transport" do
23+
typed_schema "transport" do
2424
field :name, :string
2525
field :model, :string
2626
field :manufacturer, :string

lib/swapi/schemas/vehicle.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ defmodule SWAPI.Schemas.Vehicle do
33
Vehicle schema
44
"""
55

6-
use Ecto.Schema
6+
use TypedEctoSchema
77
import Ecto.Changeset
88

99
alias SWAPI.Schemas.Film
@@ -15,7 +15,7 @@ defmodule SWAPI.Schemas.Vehicle do
1515

1616
@primary_key false
1717

18-
schema "vehicles" do
18+
typed_schema "vehicles" do
1919
belongs_to :transport, Transport, foreign_key: :id, primary_key: true, on_replace: :update
2020

2121
field :vehicle_class, :string

mix.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ defmodule SWAPI.MixProject do
3636
{:phoenix_ecto, "~> 4.4"},
3737
{:ecto_sql, "~> 3.10"},
3838
{:ecto_sqlite3, "~> 0.13"},
39+
{:typed_ecto_schema, "~> 0.4.1"},
3940
{:postgrex, ">= 0.0.0"},
4041
{:phoenix_html, "~> 3.3"},
4142
{:phoenix_live_reload, "~> 1.2", only: :dev},

mix.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"},
5353
"telemetry_metrics": {:hex, :telemetry_metrics, "0.6.1", "315d9163a1d4660aedc3fee73f33f1d355dcc76c5c3ab3d59e76e3edf80eef1f", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7be9e0871c41732c233be71e4be11b96e56177bf15dde64a8ac9ce72ac9834c6"},
5454
"telemetry_poller": {:hex, :telemetry_poller, "1.0.0", "db91bb424e07f2bb6e73926fcafbfcbcb295f0193e0a00e825e589a0a47e8453", [:rebar3], [{:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "b3a24eafd66c3f42da30fc3ca7dda1e9d546c12250a2d60d7b81d264fbec4f6e"},
55+
"typed_ecto_schema": {:hex, :typed_ecto_schema, "0.4.1", "a373ca6f693f4de84cde474a67467a9cb9051a8a7f3f615f1e23dc74b75237fa", [:mix], [{:ecto, "~> 3.5", [hex: :ecto, repo: "hexpm", optional: false]}], "hexpm", "85c6962f79d35bf543dd5659c6adc340fd2480cacc6f25d2cc2933ea6e8fcb3b"},
5556
"websock": {:hex, :websock, "0.5.3", "2f69a6ebe810328555b6fe5c831a851f485e303a7c8ce6c5f675abeb20ebdadc", [:mix], [], "hexpm", "6105453d7fac22c712ad66fab1d45abdf049868f253cf719b625151460b8b453"},
5657
"websock_adapter": {:hex, :websock_adapter, "0.5.5", "9dfeee8269b27e958a65b3e235b7e447769f66b5b5925385f5a569269164a210", [:mix], [{:bandit, ">= 0.6.0", [hex: :bandit, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.6", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:websock, "~> 0.5", [hex: :websock, repo: "hexpm", optional: false]}], "hexpm", "4b977ba4a01918acbf77045ff88de7f6972c2a009213c515a445c48f224ffce9"},
5758
}

0 commit comments

Comments
 (0)