reset

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package reset drops every table in a database, including the migration ledger.

It is a separate package because it is destructive and because most programs have no business importing it. It exists to support a "start from nothing" command in a development or test environment.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupported = errors.New("dialect does not support reset")

ErrUnsupported reports a dialect that does not implement Resetter.

Functions

func DropAll

func DropAll(ctx context.Context, db *sql.DB, dialect rung.Dialect) (int, error)

DropAll drops every table in the database, the migration ledger included, and returns how many were dropped.

This destroys all data. There is no confirmation and nothing is recoverable; asking is the caller's responsibility.

Types

type Resetter

type Resetter interface {
	// ListTablesQuery selects the names of every table in the connected
	// database or current schema, as a single column.
	ListTablesQuery() string
	// QuoteIdentifier quotes a table name for interpolation.
	QuoteIdentifier(name string) string
	// DropTablesStatement drops every already-quoted table named.
	DropTablesStatement(quoted []string) string
}

Resetter is the part of a dialect needed to drop a schema. A rung.Dialect that does not implement it cannot be reset by this package.

It is a separate, optional interface rather than part of rung.Dialect so that implementing a dialect does not oblige anyone to implement a destructive operation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL