Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/algora/payments/schemas/customer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ defmodule Algora.Payments.Customer do
|> cast(attrs, [:user_id, :provider, :provider_id, :provider_meta, :name])
|> generate_id()
|> validate_required([:user_id, :provider, :provider_id, :provider_meta, :name])
|> unique_constraint([:provider, :provider_id])
|> unique_constraint(:user_id)
|> foreign_key_constraint(:user_id)
end
Expand Down
1 change: 0 additions & 1 deletion lib/algora/payments/schemas/payment_method.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ defmodule Algora.Payments.PaymentMethod do
|> cast(attrs, [:provider, :provider_id, :provider_meta, :provider_customer_id, :is_default, :customer_id])
|> generate_id()
|> validate_required([:provider, :provider_id, :provider_meta, :provider_customer_id, :is_default, :customer_id])
|> unique_constraint([:provider, :provider_id])
|> foreign_key_constraint(:customer_id)
end
end
13 changes: 13 additions & 0 deletions priv/repo/migrations/20250228212307_drop_provider_indexes.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
defmodule Algora.Repo.Migrations.DropProviderIndexes do
use Ecto.Migration

def up do
drop unique_index(:payment_methods, [:provider, :provider_id])
drop unique_index(:customers, [:provider, :provider_id])
end

def down do
create unique_index(:payment_methods, [:provider, :provider_id])
create unique_index(:customers, [:provider, :provider_id])
end
end
6 changes: 4 additions & 2 deletions scripts/database_migration.exs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ defmodule DatabaseMigration do
{"Reward", ["bounty_id"]}
]

@test_org_id "cljo6j981000el60f1k1cvtns"

defp relevant_tables do
@schema_mappings
|> Enum.map(fn {k, _v} -> k end)
Expand Down Expand Up @@ -699,7 +701,7 @@ defmodule DatabaseMigration do
raise "Owner not found: #{inspect(row)}"
end

if owner["id"] not in ["clfqtao4h0001mo0gkp9az0bn", "cm251pvg40007ld031q5t2hj2", "cljo6j981000el60f1k1cvtns"] do
if owner["id"] != @test_org_id do
%{
"id" => row["id"],
"provider" => "stripe",
Expand All @@ -726,7 +728,7 @@ defmodule DatabaseMigration do
raise "StripeCustomer not found: #{inspect(row)}"
end

if owner["id"] not in ["clfqtao4h0001mo0gkp9az0bn", "cm251pvg40007ld031q5t2hj2", "cljo6j981000el60f1k1cvtns"] do
if owner["id"] != @test_org_id do
%{
"id" => row["id"],
"provider" => "stripe",
Expand Down