changed project/app name
This commit is contained in:
parent
4fbafbfa5e
commit
cd31432f88
89 changed files with 421 additions and 417 deletions
|
@ -1,27 +1,27 @@
|
|||
defmodule RealEstate.Repo.Migrations.CreateUsersAuthTables do
|
||||
defmodule Bones73k.Repo.Migrations.CreateUsersAuthTables do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
execute "CREATE EXTENSION IF NOT EXISTS citext", ""
|
||||
execute("CREATE EXTENSION IF NOT EXISTS citext", "")
|
||||
|
||||
create table(:users) do
|
||||
add :email, :citext, null: false
|
||||
add :hashed_password, :string, null: false
|
||||
add :confirmed_at, :naive_datetime
|
||||
add(:email, :citext, null: false)
|
||||
add(:hashed_password, :string, null: false)
|
||||
add(:confirmed_at, :naive_datetime)
|
||||
timestamps()
|
||||
end
|
||||
|
||||
create unique_index(:users, [:email])
|
||||
create(unique_index(:users, [:email]))
|
||||
|
||||
create table(:users_tokens) do
|
||||
add :user_id, references(:users, on_delete: :delete_all), null: false
|
||||
add :token, :binary, null: false
|
||||
add :context, :string, null: false
|
||||
add :sent_to, :string
|
||||
add(:user_id, references(:users, on_delete: :delete_all), null: false)
|
||||
add(:token, :binary, null: false)
|
||||
add(:context, :string, null: false)
|
||||
add(:sent_to, :string)
|
||||
timestamps(updated_at: false)
|
||||
end
|
||||
|
||||
create index(:users_tokens, [:user_id])
|
||||
create unique_index(:users_tokens, [:context, :token])
|
||||
create(index(:users_tokens, [:user_id]))
|
||||
create(unique_index(:users_tokens, [:context, :token]))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
defmodule RealEstate.Repo.Migrations.AddRoleToUsers do
|
||||
defmodule Bones73k.Repo.Migrations.AddRoleToUsers do
|
||||
use Ecto.Migration
|
||||
|
||||
alias RealEstate.Accounts.User.RolesEnum
|
||||
alias Bones73k.Accounts.User.RolesEnum
|
||||
|
||||
def up do
|
||||
RolesEnum.create_type()
|
||||
|
||||
alter table(:users) do
|
||||
add :role, RolesEnum.type(), null: false
|
||||
add(:role, RolesEnum.type(), null: false)
|
||||
end
|
||||
end
|
||||
|
||||
def down do
|
||||
alter table(:users) do
|
||||
remove :role
|
||||
remove(:role)
|
||||
end
|
||||
|
||||
RolesEnum.drop_type()
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
defmodule RealEstate.Repo.Migrations.CreateProperties do
|
||||
defmodule Bones73k.Repo.Migrations.CreateProperties do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:properties) do
|
||||
add :name, :string
|
||||
add :price, :decimal
|
||||
add :description, :text
|
||||
add :user_id, references(:users, on_delete: :nothing)
|
||||
add(:name, :string)
|
||||
add(:price, :decimal)
|
||||
add(:description, :text)
|
||||
add(:user_id, references(:users, on_delete: :nothing))
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
create index(:properties, [:user_id])
|
||||
create(index(:properties, [:user_id]))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,27 +5,27 @@
|
|||
# Inside the script, you can read and write to any of your
|
||||
# repositories directly:
|
||||
#
|
||||
# RealEstate.Repo.insert!(%RealEstate.SomeSchema{})
|
||||
# Bones73k.Repo.insert!(%Bones73k.SomeSchema{})
|
||||
#
|
||||
# We recommend using the bang functions (`insert!`, `update!`
|
||||
# and so on) as they will fail if something goes wrong.
|
||||
|
||||
{:ok, admin} =
|
||||
RealEstate.Accounts.register_admin(%{
|
||||
Bones73k.Accounts.register_admin(%{
|
||||
email: "admin@company.com",
|
||||
password: "123456789abc",
|
||||
password_confirmation: "123456789abc"
|
||||
})
|
||||
|
||||
{:ok, user_1} =
|
||||
RealEstate.Accounts.register_user(%{
|
||||
Bones73k.Accounts.register_user(%{
|
||||
email: "user1@company.com",
|
||||
password: "123456789abc",
|
||||
password_confirmation: "123456789abc"
|
||||
})
|
||||
|
||||
{:ok, user_2} =
|
||||
RealEstate.Accounts.register_user(%{
|
||||
Bones73k.Accounts.register_user(%{
|
||||
email: "user2@company.com",
|
||||
password: "123456789abc",
|
||||
password_confirmation: "123456789abc"
|
||||
|
@ -38,7 +38,7 @@ Enum.each(1..10, fn i ->
|
|||
description: "Property that belongs to user 1",
|
||||
user_id: user_1.id
|
||||
}
|
||||
|> RealEstate.Properties.create_property()
|
||||
|> Bones73k.Properties.create_property()
|
||||
|
||||
%{
|
||||
name: "Property #{i} - User 2",
|
||||
|
@ -46,7 +46,7 @@ Enum.each(1..10, fn i ->
|
|||
description: "Property that belongs to user 2",
|
||||
user_id: user_2.id
|
||||
}
|
||||
|> RealEstate.Properties.create_property()
|
||||
|> Bones73k.Properties.create_property()
|
||||
|
||||
%{
|
||||
name: "Property #{i} - Admin",
|
||||
|
@ -54,5 +54,5 @@ Enum.each(1..10, fn i ->
|
|||
description: "Property that belongs to admin",
|
||||
user_id: admin.id
|
||||
}
|
||||
|> RealEstate.Properties.create_property()
|
||||
|> Bones73k.Properties.create_property()
|
||||
end)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue