SQLStreams

the messaging platform that is just Postgres

You last visited on 9999-99-99 Show what's new since then

Delete a stream

Edit this page
Stream · Related pages
Posted: 2026-09-16 · Report this thread
brandon Site Admin brandon profile Posts: 96
Destroy(ctx context.Context, options *DestroyOptions) error

Permanently deletes the stream, its messages, consumer groups, and associated stream tables. The default guard refuses deletion while the message log contains any messages, including messages already processed by every group.

Example

Delete the empty payments.requested stream using an initialized client created with ClientConfig.AllowDestroy enabled. Stop applications using the stream before deletion.

payments := client.Stream[sqlstreams.RawPayload]("payments.requested")
if err := payments.Destroy(ctx, nil); err != nil {
return err
}

Parameters

Parameter Type Required Description
ctx context.Context Yes Cancellation or its deadline interrupts deletion. Partitions removed by earlier steps remain deleted.
options *DestroyOptions No nil retains the empty-stream guard.

DestroyOptions

Field Type Default Description
Force bool false Allows deletion while messages remain. Does not bypass ClientConfig.AllowDestroy or stop running applications.

Returns

Condition Return value
Deletion succeeds nil.
Deletion is refused or fails A non-nil error.

CLI

sqlstreams stream destroy payments.requested --yes

--yes skips the confirmation prompt. Add --force to delete a nonempty stream. Without --yes, an interactive terminal requires typing the stream name. Noninteractive execution and --output json require --yes.

Errors

Error When
ErrDestroyDisabled The client was created without AllowDestroy.
Validation error The stream name is empty.
ErrReservedStreamName The name starts with __system..
ErrStreamNotFound The stream is absent.
ErrStreamNotEmpty Messages remain and Force is false.
ErrStreamPartitionsRemain Partition removal cannot finish, for example while producers create new partitions.
Database or context error A deletion step fails or is interrupted.