Skip to content

stack: keep a project directory's stack across git branch changes, and add a prune command for stacks that no longer match a directory #7568

Closed

Description

@luizfneves404

Existing issues

  • I have searched the existing issues.

Affected area

Local development

Problem to solve

A managed stack is identified by the project root, the branch context and the stack name (packages/stack/src/identity/Identity.ts, deriveStackId). When the branch context changes, the directory stops selecting its stack, and the old stack stays where it is.

Observed on Supabase CLI 3.1.0: we created a stack in a project directory that was not a git repository (branch context ordinary-workspace). After git init on a main branch, supabase --experimental stack status reported "No managed stack exists for the selected project", while supabase --experimental stack list still listed the old stack under ordinary-workspace.

Nothing removes such stacks in bulk. The stack subcommands at 3.1.0 are destroy, install, list, logs, outdated, restart, start, status, stop and update. destroy takes a stack id and requires --yes; nothing finds the stacks whose directory no longer exists or no longer selects them.

Proposed solution

  1. An option that takes the branch out of the stack identity, so a directory keeps its stack when it changes branch, for example supabase stack start --ignore-branch.
  2. supabase stack prune, which lists the stacks whose project root no longer exists or no longer selects them, and removes them with --yes. Dry run by default.

Alternatives considered

Destroying each stack by id with supabase stack destroy --stack-id <stack id> --yes. This works, but the ids have to be found first, and nothing lists the orphans.

Additional context

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions