From 065e3f2e2c9842931db513b6a95e706675ac19e2 Mon Sep 17 00:00:00 2001 From: nelsonic Date: Sat, 8 Jun 2024 15:20:17 +0100 Subject: [PATCH] alphabetize schema field list #13 --- BUILDIT.md | 6 +++--- lib/app/user.ex | 2 +- .../migrations/20221005213110_create_users.exs | 12 ++++++------ .../20221005213326_create_repositories.exs | 14 +++++++------- test/app/repository_test.exs | 4 +++- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/BUILDIT.md b/BUILDIT.md index 3d3f7e5..cbd5af6 100644 --- a/BUILDIT.md +++ b/BUILDIT.md @@ -435,7 +435,7 @@ This app stores data in **five** schemas: For each of these schemas we are storing a _subset_ of the data; -only what we need right now. +only what we need right now.
We can always add more ("[backfill](https://stackoverflow.com/questions/70871818/what-is-backfilling-in-data)") later as needed. @@ -450,8 +450,8 @@ commands: ```sh mix phx.gen.schema User users login:string avatar_url:string name:string company:string bio:string blog:string location:string email:string created_at:string two_factor_authentication:boolean followers:integer following:integer mix phx.gen.schema Org orgs login:string avatar_url:string name:string company:string public_repos:integer location:string description:string followers:integer -mix phx.gen.schema Repository repositories name:string full_name:string owner_id:integer description:string fork:boolean forks_count:integer watchers_count:integer stargazers_count:integer topics:string open_issues_count:integer created_at:string pushed_at:string - +mix phx.gen.schema Repository repositories name:string full_name:string owner_id:integer owner_name:string description:string fork:boolean forks_count:integer watchers_count:integer stargazers_count:integer topics:string open_issues_count:integer created_at:string pushed_at:string +mix phx.gen.schema Stars stars repo_id:integer ``` At the end of this step, diff --git a/lib/app/user.ex b/lib/app/user.ex index ab484b1..8e116ca 100644 --- a/lib/app/user.ex +++ b/lib/app/user.ex @@ -18,8 +18,8 @@ defmodule App.User do field :location, :string field :login, :string field :name, :string - field :two_factor_authentication, :boolean, default: false field :public_repos, :integer + field :two_factor_authentication, :boolean, default: false timestamps() end diff --git a/priv/repo/migrations/20221005213110_create_users.exs b/priv/repo/migrations/20221005213110_create_users.exs index bfe3f83..24297cb 100644 --- a/priv/repo/migrations/20221005213110_create_users.exs +++ b/priv/repo/migrations/20221005213110_create_users.exs @@ -4,19 +4,19 @@ defmodule App.Repo.Migrations.CreateUsers do def change do create table(:users) do add :avatar_url, :string - add :login, :string - add :name, :string - add :company, :string add :bio, :string add :blog, :string - add :location, :string - add :email, :string + add :company, :string add :created_at, :string - add :two_factor_authentication, :boolean, default: false, null: false + add :email, :string add :followers, :integer add :following, :integer add :hireable, :boolean, default: false, null: false + add :location, :string + add :login, :string + add :name, :string add :public_repos, :integer + add :two_factor_authentication, :boolean, default: false, null: false timestamps() end diff --git a/priv/repo/migrations/20221005213326_create_repositories.exs b/priv/repo/migrations/20221005213326_create_repositories.exs index eca4df1..3162ad6 100644 --- a/priv/repo/migrations/20221005213326_create_repositories.exs +++ b/priv/repo/migrations/20221005213326_create_repositories.exs @@ -3,18 +3,18 @@ defmodule App.Repo.Migrations.CreateRepositories do def change do create table(:repositories) do - add :name, :string - add :full_name, :string - add :owner_id, :integer + add :created_at, :string add :description, :string add :fork, :boolean, default: false, null: false add :forks_count, :integer - add :watchers_count, :integer - add :stargazers_count, :integer - add :topics, :string + add :full_name, :string + add :name, :string add :open_issues_count, :integer - add :created_at, :string + add :owner_id, :integer add :pushed_at, :string + add :stargazers_count, :integer + add :topics, :string + add :watchers_count, :integer timestamps() end diff --git a/test/app/repository_test.exs b/test/app/repository_test.exs index 7aa9396..52809a0 100644 --- a/test/app/repository_test.exs +++ b/test/app/repository_test.exs @@ -9,6 +9,8 @@ defmodule App.RepositoryTest do forks_count: 110, full_name: "dwyl/start-here", id: 17338019, + owner_id: 123, + owner_name: "dwyl", name: "start-here", open_issues_count: 98, pushed_at: "2022-08-10T07:41:05Z", @@ -20,4 +22,4 @@ defmodule App.RepositoryTest do assert {:ok, inserted_repo} = App.Repository.create(repo) assert inserted_repo.name == repo.name end -end \ No newline at end of file +end