defmodule SimpleshopTheme.Repo.Migrations.CreateProviderConnections do
  use Ecto.Migration

  def change do
    create table(:provider_connections, primary_key: false) do
      add :id, :binary_id, primary_key: true
      add :provider_type, :string, null: false
      add :name, :string, null: false
      add :enabled, :boolean, default: true, null: false
      add :api_key_encrypted, :binary
      add :config, :map, default: %{}
      add :last_synced_at, :utc_datetime
      add :sync_status, :string, default: "pending"

      timestamps(type: :utc_datetime)
    end

    create unique_index(:provider_connections, [:provider_type])
  end
end
