migration

package
v1.15.3 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2025 License: MIT Imports: 28 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ChangePatterns = []string{
	`_(to|from|in)_(\w+)_table$`,
	`_(to|from|in)_(\w+)$`,
}
View Source
var CreatePatterns = []string{
	`^create_(\w+)_table$`,
	`^create_(\w+)$`,
}

Functions

func CreateTestMigrations

func CreateTestMigrations(driver database.Driver)

Types

type Agent

type Agent struct {
	ID        uint `gorm:"primaryKey" json:"id"`
	Name      string
	CreatedAt carbon.DateTime `gorm:"autoCreateTime;column:created_at" json:"created_at"`
	UpdatedAt carbon.DateTime `gorm:"autoUpdateTime;column:updated_at" json:"updated_at"`
}

type DefaultCreator

type DefaultCreator struct {
}

func NewDefaultCreator

func NewDefaultCreator() *DefaultCreator

func (*DefaultCreator) GetFileName

func (r *DefaultCreator) GetFileName(name string) string

GetFileName Get the full path to the migration.

func (*DefaultCreator) GetPath

func (r *DefaultCreator) GetPath(name string) string

GetPath Get the full path to the migration.

func (*DefaultCreator) GetStub

func (r *DefaultCreator) GetStub(table string, create bool) string

GetStub Get the migration stub file.

func (*DefaultCreator) PopulateStub

func (r *DefaultCreator) PopulateStub(stub, signature, table string) string

PopulateStub Populate the place-holders in the migration stub.

type DefaultMigrator

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

func NewDefaultMigrator

func NewDefaultMigrator(artisan console.Artisan, schema contractsschema.Schema, table string) *DefaultMigrator

func (*DefaultMigrator) Create

func (r *DefaultMigrator) Create(name string) error

func (*DefaultMigrator) Fresh

func (r *DefaultMigrator) Fresh() error

TODO Remove this function and move the logic to the migrate:fresh command when the sql migrator is removed.

func (*DefaultMigrator) Reset

func (r *DefaultMigrator) Reset() error

func (*DefaultMigrator) Rollback

func (r *DefaultMigrator) Rollback(step, batch int) error

func (*DefaultMigrator) Run

func (r *DefaultMigrator) Run() error

func (*DefaultMigrator) Status

type MysqlStubs

type MysqlStubs struct {
}

func (MysqlStubs) CreateDown

func (receiver MysqlStubs) CreateDown() string

CreateDown Create down migration content.

func (MysqlStubs) CreateUp

func (receiver MysqlStubs) CreateUp() string

CreateUp Create up migration content.

func (MysqlStubs) UpdateDown

func (receiver MysqlStubs) UpdateDown() string

UpdateDown Update down migration content.

func (MysqlStubs) UpdateUp

func (receiver MysqlStubs) UpdateUp() string

UpdateUp Update up migration content.

type PostgresStubs

type PostgresStubs struct {
}

func (PostgresStubs) CreateDown

func (receiver PostgresStubs) CreateDown() string

CreateDown Create down migration content.

func (PostgresStubs) CreateUp

func (receiver PostgresStubs) CreateUp() string

CreateUp Create up migration content.

func (PostgresStubs) UpdateDown

func (receiver PostgresStubs) UpdateDown() string

UpdateDown Update down migration content.

func (PostgresStubs) UpdateUp

func (receiver PostgresStubs) UpdateUp() string

UpdateUp Update up migration content.

type Repository

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

func NewRepository

func NewRepository(schema schema.Schema, table string) *Repository

func (*Repository) CreateRepository

func (r *Repository) CreateRepository() error

func (*Repository) Delete

func (r *Repository) Delete(migration string) error

func (*Repository) DeleteRepository

func (r *Repository) DeleteRepository() error

func (*Repository) GetLast

func (r *Repository) GetLast() ([]migration.File, error)

func (*Repository) GetMigrations

func (r *Repository) GetMigrations() ([]migration.File, error)

func (*Repository) GetMigrationsByBatch

func (r *Repository) GetMigrationsByBatch(batch int) ([]migration.File, error)

func (*Repository) GetMigrationsByStep

func (r *Repository) GetMigrationsByStep(steps int) ([]migration.File, error)

func (*Repository) GetNextBatchNumber

func (r *Repository) GetNextBatchNumber() (int, error)

func (*Repository) GetRan

func (r *Repository) GetRan() ([]string, error)

func (*Repository) Log

func (r *Repository) Log(file string, batch int) error

func (*Repository) RepositoryExists

func (r *Repository) RepositoryExists() bool

type SqlCreator

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

func NewSqlCreator

func NewSqlCreator(driver database.Driver, charset string) *SqlCreator

func (*SqlCreator) GetPath

func (r *SqlCreator) GetPath(name string, category string) string

GetPath Get the full path to the migration.

func (*SqlCreator) GetStub

func (r *SqlCreator) GetStub(table string, create bool) (string, string)

GetStub Get the migration stub file.

func (*SqlCreator) PopulateStub

func (r *SqlCreator) PopulateStub(stub string, table string) string

PopulateStub Populate the place-holders in the migration stub.

type SqlMigrator

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

TODO Remove in v1.16

func NewSqlMigrator

func NewSqlMigrator(config config.Config) (*SqlMigrator, error)

func (*SqlMigrator) Create

func (r *SqlMigrator) Create(name string) error

func (*SqlMigrator) Fresh

func (r *SqlMigrator) Fresh() error

func (*SqlMigrator) Reset

func (r *SqlMigrator) Reset() error

func (*SqlMigrator) Rollback

func (r *SqlMigrator) Rollback(step, batch int) error

func (*SqlMigrator) Run

func (r *SqlMigrator) Run() error

func (*SqlMigrator) Status

func (r *SqlMigrator) Status() ([]migration.Status, error)

type SqliteStubs

type SqliteStubs struct {
}

func (SqliteStubs) CreateDown

func (receiver SqliteStubs) CreateDown() string

CreateDown Create down migration content.

func (SqliteStubs) CreateUp

func (receiver SqliteStubs) CreateUp() string

CreateUp Create up migration content.

func (SqliteStubs) UpdateDown

func (receiver SqliteStubs) UpdateDown() string

UpdateDown Update down migration content.

func (SqliteStubs) UpdateUp

func (receiver SqliteStubs) UpdateUp() string

UpdateUp Update up migration content.

type SqlserverStubs

type SqlserverStubs struct {
}

func (SqlserverStubs) CreateDown

func (receiver SqlserverStubs) CreateDown() string

CreateDown Create down migration content.

func (SqlserverStubs) CreateUp

func (receiver SqlserverStubs) CreateUp() string

CreateUp Create up migration content.

func (SqlserverStubs) UpdateDown

func (receiver SqlserverStubs) UpdateDown() string

UpdateDown Update down migration content.

func (SqlserverStubs) UpdateUp

func (receiver SqlserverStubs) UpdateUp() string

UpdateUp Update up migration content.

type Stubs

type Stubs struct {
}

func (Stubs) Create

func (receiver Stubs) Create() string

func (Stubs) Empty

func (receiver Stubs) Empty() string

func (Stubs) Update

func (receiver Stubs) Update() string

type TableGuesser

type TableGuesser struct {
}

func (TableGuesser) Guess

func (receiver TableGuesser) Guess(migration string) (string, bool)

Guess Attempt to guess the table name and "creation" status of the given migration, return table, create.

Jump to

Keyboard shortcuts

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