Documentation
¶
Index ¶
- Constants
- Variables
- func CobraParseMigrateDownArgs(args []string) (n int, err error)
- func CobraParseMigrateUpArgs(args []string) (n int, err error)
- func TablesWithColumn(fsys embed.FS, root string, columnName string) (map[string]bool, error)
- type ConnectionOptions
- type MigrationSet
- func (s MigrationSet) Create(name string) (fileName string, err error)
- func (s MigrationSet) Down(opts ConnectionOptions, max int) (n int, err error)
- func (s MigrationSet) Status(opts ConnectionOptions) (plans []*migrate.PlannedMigration, err error)
- func (s MigrationSet) Up(opts ConnectionOptions, max int) (n int, err error)
- type NewMigrationSetOptions
- type PartmanMaintainer
- type TemplateMigrationSource
Constants ¶
View Source
const CobraMigrateDownShort = "" /* 149-byte string literal not displayed */
View Source
const CobraMigrateDownUse = "down n"
View Source
const CobraMigrateStatusShort = "Get database schema migration status"
View Source
const CobraMigrateStatusUse = "status"
View Source
const CobraMigrateUpShort = "Migrate at most n versions up. When n is omitted, migrate to latest version. n must be a positive integer."
View Source
const CobraMigrateUpUse = "up [n]"
Variables ¶
View Source
var CobraMigrateDownArgs = cobra.ExactArgs(1)
View Source
var CobraMigrateStatusArgs = cobra.ExactArgs(0)
View Source
var CobraMigrateUpArgs = cobra.MaximumNArgs(1)
Functions ¶
func CobraParseMigrateUpArgs ¶
func TablesWithColumn ¶
TablesWithColumn statically replays every migration's Up statements, in migration order, and returns the set of tables that currently exist (i.e. have been CREATE TABLE'd and not since DROP TABLE'd) and were created with a column named columnName. It requires no database connection.
It only understands the plain `CREATE TABLE name (...)` and `DROP TABLE name` statement forms used by this repo's migrations today (no ALTER TABLE ADD/DROP COLUMN, no CREATE TABLE ... AS, no multi-table DROP TABLE a, b). If a future migration needs one of those forms for a table this function is used to track, this function needs updating too.
Types ¶
type ConnectionOptions ¶
type MigrationSet ¶
type MigrationSet struct {
MigrationSet migrate.MigrationSet
EmbedFS embed.FS
EmbedFSRoot string
OutputPathRelativeToWorkingDirectory string
}
func NewMigrateSet ¶
func NewMigrateSet(options NewMigrationSetOptions) MigrationSet
func (MigrationSet) Down ¶
func (s MigrationSet) Down(opts ConnectionOptions, max int) (n int, err error)
func (MigrationSet) Status ¶
func (s MigrationSet) Status(opts ConnectionOptions) (plans []*migrate.PlannedMigration, err error)
func (MigrationSet) Up ¶
func (s MigrationSet) Up(opts ConnectionOptions, max int) (n int, err error)
type NewMigrationSetOptions ¶
type NewMigrationSetOptions struct {
// TableName is the name of the table that stores migration status.
TableName string
// EmbedFS is a embed.FS that stores migration files.
// You also pass in a correct EmbedFSRoot to tell where to find the migrations.
// Suppose you write //go:embed migrations/authgear
// then EmbedFSRoot MUST BE "migrations/authgear" (no leading slash nor trailing slash)
EmbedFS embed.FS
EmbedFSRoot string
// OutputPathRelativeToWorkingDirectory is for the create command.
// The create command create new file in the actual filesystem, so
// it is relative to workdir.
OutputPathRelativeToWorkingDirectory string
}
type PartmanMaintainer ¶
func (PartmanMaintainer) RunMaintenance ¶
func (m PartmanMaintainer) RunMaintenance() (err error)
type TemplateMigrationSource ¶
type TemplateMigrationSource struct {
OriginSource migrate.MigrationSource
Data any
}
func (TemplateMigrationSource) ExecuteTemplate ¶
func (s TemplateMigrationSource) ExecuteTemplate(input string) (out string, err error)
func (TemplateMigrationSource) FindMigrations ¶
func (s TemplateMigrationSource) FindMigrations() (migrations []*migrate.Migration, err error)
Click to show internal directories.
Click to hide internal directories.