defmodule WandererApp.Repo.Migrations.AddCorpWalletTransactions do
  @moduledoc """
  Updates resources based on their most recent snapshots.

  This file was autogenerated with `mix ash_postgres.generate_migrations`
  """

  use Ecto.Migration

  def up do
    alter table(:user_transaction_v1) do
      modify :amount, :float
    end

    create table(:corp_wallet_transactions_v1, primary_key: false) do
      add :id, :uuid, null: false, default: fragment("gen_random_uuid()"), primary_key: true
      add :eve_transaction_id, :bigint, null: false
      add :amount, :float, null: false
      add :balance, :float, null: false
      add :first_party_id, :bigint, null: false
      add :second_party_id, :bigint, null: false
      add :date, :utc_datetime
      add :description, :text
      add :reason, :text
      add :ref_type, :text

      add :inserted_at, :utc_datetime_usec,
        null: false,
        default: fragment("(now() AT TIME ZONE 'utc')")

      add :updated_at, :utc_datetime_usec,
        null: false,
        default: fragment("(now() AT TIME ZONE 'utc')")
    end
  end

  def down do
    drop table(:corp_wallet_transactions_v1)

    alter table(:user_transaction_v1) do
      modify :amount, :bigint
    end
  end
end
