Documentation
¶
Index ¶
- func AddColumn(config *CONFIG, db *pgxpool.Pool, table string, columns string) error
- func CreateEmptyMigration(migrationDir, name string) error
- func CreateTable(config *CONFIG, db *pgxpool.Pool, table string, columns string) error
- func DBConnection(config *CONFIG) *pgxpool.Pool
- func DeleteColumn(config *CONFIG, db *pgxpool.Pool, table string, columns string) error
- func GenerateSQLC(config *CONFIG) error
- func InitSQLC(config *CONFIG) error
- func InsertData(config *CONFIG, db *pgxpool.Pool, table string, data string) error
- func MigrateUp(config *CONFIG, db *pgxpool.Pool) error
- func ReadColumnOfTable(db *pgxpool.Pool, table string) ([]string, error)
- func ResetSequenceOfTable(db *pgxpool.Pool, table string) error
- func Rollback(config *CONFIG, db *pgxpool.Pool, count int) error
- func RollbackAll(config *CONFIG, db *pgxpool.Pool) error
- func SelectMany(config *CONFIG, db *pgxpool.Pool, table string, columns string, where string, ...) error
- func SelectOne(config *CONFIG, db *pgxpool.Pool, table string, columns string, where string) error
- func ShowMigrationStatus(config *CONFIG) error
- func SoftDelete(config *CONFIG, db *pgxpool.Pool, table string, where string) error
- func UpdateData(config *CONFIG, db *pgxpool.Pool, table string, data string, where string) error
- type CONFIG
- type MigrationScript
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddColumn ¶
Add Column to Table @param config: *CONFIG @param db: *pgxpool.Pool @param table: string @param columns: string
func CreateEmptyMigration ¶
Create empty migration file with goose template @param migrationDir string @param name string @return error
func CreateTable ¶
Add Column to Table @param db: *pgxpool.Pool @param table: string @param column: string
func DBConnection ¶
func DeleteColumn ¶
Delete Column from Table @param config: *CONFIG @param db: *pgxpool.Pool @param table: string @param columns: string
func GenerateSQLC ¶
Generate SQLC code from database @param config *CONFIG @return error
func InsertData ¶ added in v1.1.0
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 ReadColumnOfTable ¶
Read Column of Table @param db *pgxpool.Pool @param table string @return []string, error
func ResetSequenceOfTable ¶
ResetSequenceOfTable reset sequence of table @param db: *pgxpool.Pool @param table: string
func Rollback ¶
Rollback migrations by count @param config: util.Config @param db: *pgxpool.Pool @param count: int - number of migrations to rollback
func RollbackAll ¶
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
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 ¶
ShowMigrationStatus - public wrapper for showing migration status
func SoftDelete ¶ added in v1.1.0
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
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 ¶
type MigrationScript ¶
type MigrationScript string
const ( MigrationScriptUp MigrationScript = "up" MigrationScriptDown MigrationScript = "down" MigrationScriptStatus MigrationScript = "status" )