-
Notifications
You must be signed in to change notification settings - Fork 317
Description
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
I am using branching and I have a persistent branch called next and I had another feature branch. The feature branch had one new migration file that was doing bunch of stuff like adding new db table, updating existing tables and db function, adding new constraints, and so on. When I merged the feature branch to next, migration in the Supabase dashboard is shown as failed but it seems like it was applied because I see the table added by the migration now and I also see the migration added to schema_migrations table.
Btw the migration was supposed to fail because existing data violates the newly added constraint.
Migration looks something like:
create table wallet.cashu_proofs (
"id" uuid primary key default gen_random_uuid(),
"user_id" uuid not null references wallet.users (id) on delete cascade,
...
);
...
alter table wallet.cashu_send_swaps add column requires_input_proofs_swap boolean generated always as (amount_to_send != input_amount) stored;
alter table wallet.cashu_send_swaps add constraint cashu_send_swaps_keyset_required_check
check (
(requires_input_proofs_swap = false) or
(requires_input_proofs_swap = true and keyset_id is not null and keyset_counter is not null)
);
...
The full migration file can be seen here and the error I see in the Supabase dashboard is:
Applying migration 20251119133559_cashu_proofs_changes.sql...
NOTICE (00000): type "wallet.cashu_proof_input" does not exist, skipping
NOTICE (00000): type "wallet.add_cashu_proofs_and_update_account_result" does not exist, skipping
NOTICE (00000): index "cashu_send_quotes_quote_id_key" does not exist, skipping
NOTICE (00000): type "wallet.complete_cashu_send_quote_result" does not exist, skipping
NOTICE (00000): type "wallet.expire_cashu_send_quote_result" does not exist, skipping
NOTICE (00000): type "wallet.fail_cashu_send_quote_result" does not exist, skipping
2025/11/24 21:26:50 ERROR: check constraint "cashu_send_swaps_keyset_required_check" of relation "cashu_send_swaps" is violated by some row (SQLSTATE 23514)
At statement: 99
-- Add constraint: keyset_id and keyset_counter are required when requires_input_proofs_swap is true
alter table wallet.cashu_send_swaps add constraint cashu_send_swaps_keyset_required_check
check (
(requires_input_proofs_swap = false) or
(requires_input_proofs_swap = true and keyset_id is not null and keyset_counter is not null)
)
To Reproduce
Don't know how to reproduce. I tried to reproduce locally but didn't manage to.
Expected behavior
Since the migration was adding new constraint and existing data didn't satisfy that constraint, the migration should have failed and rolled back.
Screenshots
Migrations:
Proof that migration seems to have been applied: