Skip to content

PGMQ queue creation fails on preview branch reset: relation "pgmq.q_my_queue_msg_id_seq" does not exist #4492

@ToJen

Description

@ToJen

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

When resetting a Supabase preview branch, PGMQ queue creation fails with a sequence-related error. The pgmq.create() call for a queue (e.g., my_queue) references a sequence (pgmq.q_my_queue_msg_id_seq) that doesn't exist, causing the migration to fail.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Create a preview branch with migrations that create PGMQ queues:
   CREATE EXTENSION IF NOT EXISTS pgmq;
   SELECT pgmq.create('my_queue');
   SELECT pgmq.create('my_queue_dlq');
  1. Let the branch build successfully (first build works).
  2. Reset the preview branch via the Supabase dashboard.
  1. The branch rebuilds and the migration fails.
  2. View the logs of the latest build
  3. See error

Expected behavior

  • Queues should be created successfully on branch reset.
  • PGMQ extension state should be consistent after reset.
  • No sequence-related errors should occur.

Actual behavior

  • Migration fails with:
  ERROR: relation "pgmq.q_my_queue_msg_id_seq" does not exist (SQLSTATE 42P01)
  At statement: 786
  SELECT pgmq.create('my_queue_dlq')
  • The first queue (my_queue) may be created, but the second queue (my_queue_dlq) fails.
  • This only occurs on branch reset, not on first build or new commits.

System information

  • Supabase: Preview branch reset functionality
  • PGMQ extension: Latest version (via CREATE EXTENSION IF NOT EXISTS pgmq)
  • Migration file: Baseline migration or any migration creating PGMQ queues

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions