defmodule Towerops.Repo.Migrations.AddFirstLastNameToUsers do
  use Ecto.Migration

  def change do
    alter table(:users) do
      add :first_name, :string
      add :last_name, :string
    end

    # Migrate existing name data to first_name
    execute "UPDATE users SET first_name = name WHERE name IS NOT NULL", ""

    alter table(:users) do
      remove :name, :string
    end
  end
end
