migroCMD

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddColumn

func AddColumn(config *CONFIG, db *pgxpool.Pool, table string, columns string) error

Add Column to Table @param config: *CONFIG @param db: *pgxpool.Pool @param table: string @param columns: string

func CreateEmptyMigration

func CreateEmptyMigration(migrationDir, name string) error

Create empty migration file with goose template @param migrationDir string @param name string @return error

func CreateTable

func CreateTable(config *CONFIG, db *pgxpool.Pool, table string, columns string) error

Add Column to Table @param db: *pgxpool.Pool @param table: string @param column: string

func DBConnection

func DBConnection(config *CONFIG) *pgxpool.Pool

func DeleteColumn

func DeleteColumn(config *CONFIG, db *pgxpool.Pool, table string, columns string) error

Delete Column from Table @param config: *CONFIG @param db: *pgxpool.Pool @param table: string @param columns: string

func GenerateSQLC

func GenerateSQLC(config *CONFIG) error

Generate SQLC code from database @param config *CONFIG @return error

func InitSQLC added in v1.3.0

func InitSQLC(config *CONFIG) error

Initialize SQLC configuration @param config *CONFIG @return error

func InsertData added in v1.1.0

func InsertData(config *CONFIG, db *pgxpool.Pool, table string, data string) error

Insert data into table @param config *CONFIG @param db *pgxpool.Pool @param table string @param data string (format: "column1=value1,column2=value2") @return error

func MigrateUp

func MigrateUp(config *CONFIG, db *pgxpool.Pool) error

func ReadColumnOfTable

func ReadColumnOfTable(db *pgxpool.Pool, table string) ([]string, error)

Read Column of Table @param db *pgxpool.Pool @param table string @return []string, error

func ResetSequenceOfTable

func ResetSequenceOfTable(db *pgxpool.Pool, table string) error

ResetSequenceOfTable reset sequence of table @param db: *pgxpool.Pool @param table: string

func Rollback

func Rollback(config *CONFIG, db *pgxpool.Pool, count int) error

Rollback migrations by count @param config: util.Config @param db: *pgxpool.Pool @param count: int - number of migrations to rollback

func RollbackAll

func RollbackAll(config *CONFIG, db *pgxpool.Pool) error

Rollback all migrations @param config *CONFIG @param db *pgxpool.Pool @return error

func SelectMany added in v1.1.0

func SelectMany(config *CONFIG, db *pgxpool.Pool, table string, columns string, where string, limit int) error

Select many records from table @param config *CONFIG @param db *pgxpool.Pool @param table string @param columns string (optional, default: "*") @param where string (optional, format: "status='active'") @param limit int (optional, default: 100) @return error

func SelectOne added in v1.1.0

func SelectOne(config *CONFIG, db *pgxpool.Pool, table string, columns string, where string) error

Select one record from table @param config *CONFIG @param db *pgxpool.Pool @param table string @param columns string (optional, default: "*") @param where string (format: "id=1") @return error

func ShowMigrationStatus

func ShowMigrationStatus(config *CONFIG) error

ShowMigrationStatus - public wrapper for showing migration status

func SoftDelete added in v1.1.0

func SoftDelete(config *CONFIG, db *pgxpool.Pool, table string, where string) error

Soft delete record (update deleted_at) @param config *CONFIG @param db *pgxpool.Pool @param table string @param where string (format: "id=1") @return error

func UpdateData added in v1.1.0

func UpdateData(config *CONFIG, db *pgxpool.Pool, table string, data string, where string) error

Update data in table @param config *CONFIG @param db *pgxpool.Pool @param table string @param data string (format: "column1=value1,column2=value2") @param where string (format: "id=1" or "name='test'") @return error

Types

type CONFIG

type CONFIG struct {
	ENV                        string `mapstructure:"ENV"`
	DATABASE_DRIVER            string `mapstructure:"DATABASE_DRIVER"`
	DATABASE_HOST              string `mapstructure:"DATABASE_HOST"`
	DATABASE_PORT              string `mapstructure:"DATABASE_PORT"`
	DATABASE_USERNAME          string `mapstructure:"DATABASE_USERNAME"`
	DATABASE_PASSWORD          string `mapstructure:"DATABASE_PASSWORD"`
	DATABASE_NAME              string `mapstructure:"DATABASE_NAME"`
	DATABASE_CONNECTION_STRING string `mapstructure:"DATABASE_CONNECTION_STRING"`
	TIMEOUT_SECONDS            int    `mapstructure:"TIMEOUT_SECONDS"`
	MIGRATION_DIR              string `mapstructure:"MIGRATION_DIR"`
	QUERY_DIR                  string `mapstructure:"QUERY_DIR"`
	SQLC_DIR                   string `mapstructure:"SQLC_DIR"`
}

func LoadConfig

func LoadConfig(configPath string) (*CONFIG, error)

type MigrationScript

type MigrationScript string
const (
	MigrationScriptUp     MigrationScript = "up"
	MigrationScriptDown   MigrationScript = "down"
	MigrationScriptStatus MigrationScript = "status"
)

Jump to

Keyboard shortcuts

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