Skip to main content

Rollback

Rolls back the most recently applied migration for the given prefix by executing its corresponding _down.sql file from the provided fs.FS.

def Rollback(
ctx: context.Context,
db: *sqlx.DB,
prefix: string,
migrations: fs.FS
) - > error

Rolls back the most recently applied migration for the given prefix by executing its corresponding _down.sql file from the provided fs.FS.

Parameters

NameTypeDescription
ctxcontext.ContextThe context for the database operations, allowing for cancellation and timeouts.
db*sqlx.DBThe database connection pool to execute the rollback migration against.
prefixstringThe prefix used to identify and filter the relevant migrations in the schema_migrations table.
migrationsfs.FSThe file system containing the migration files, including the _down.sql file for the rollback.

Returns

TypeDescription
errorAn error if the rollback fails at any stage, otherwise nil.