schema

package
v0.0.0-...-3352087 Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package schema provides sql schema migrations for sqlq.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(c *sql.DB) (err error)

Apply applies any pending schema migration on the database.

func Teardown

func Teardown(c *sql.DB) (err error)

Teardown tears down the sql migrations and drop the default schema

Types

type EmbeddedMigration

type EmbeddedMigration struct {
	// contains filtered or unexported fields
}

func (*EmbeddedMigration) Apply

func (e *EmbeddedMigration) Apply(tx *sql.Tx) error

func (*EmbeddedMigration) Name

func (e *EmbeddedMigration) Name() string

func (*EmbeddedMigration) Version

func (e *EmbeddedMigration) Version() (v int)

type EmbeddedMigrations

type EmbeddedMigrations []*EmbeddedMigration

func ReadMigrations

func ReadMigrations(root embed.FS) EmbeddedMigrations

func (EmbeddedMigrations) Len

func (e EmbeddedMigrations) Len() int

func (EmbeddedMigrations) Less

func (e EmbeddedMigrations) Less(i, j int) bool

func (EmbeddedMigrations) Swap

func (e EmbeddedMigrations) Swap(i, j int)

type Migration

type Migration interface {

	// Name returns the user-friendly name of the migration.
	Name() string

	// Version returns an incremental version number for this migration
	Version() int

	// Apply applies the given migration to the provided connection
	Apply(*sql.Tx) error
}

Migration represents a single sql migration, that can apply any combination of DDL + DML to alter the database.

Jump to

Keyboard shortcuts

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