29 lines
785 B
Elixir
29 lines
785 B
Elixir
|
|
defmodule MyFirstElixirVibeCode.Repo.Migrations.UpdateClientFieldsInReviews do
|
||
|
|
use Ecto.Migration
|
||
|
|
|
||
|
|
def change do
|
||
|
|
alter table(:reviews) do
|
||
|
|
# Remove old fields
|
||
|
|
remove :client_name
|
||
|
|
remove :client_address
|
||
|
|
|
||
|
|
# Add split name fields
|
||
|
|
add :client_first_name, :string
|
||
|
|
add :client_last_name, :string
|
||
|
|
|
||
|
|
# Add address components
|
||
|
|
add :client_street_address, :string
|
||
|
|
add :client_city, :string
|
||
|
|
add :client_state, :string
|
||
|
|
add :client_zip, :string
|
||
|
|
add :client_country, :string
|
||
|
|
end
|
||
|
|
|
||
|
|
# Create indexes for searching
|
||
|
|
create index(:reviews, [:client_first_name])
|
||
|
|
create index(:reviews, [:client_last_name])
|
||
|
|
create index(:reviews, [:client_street_address])
|
||
|
|
create index(:reviews, [:client_city])
|
||
|
|
end
|
||
|
|
end
|