gograte

package module
v0.0.0-...-0c406a3 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2022 License: MIT Imports: 7 Imported by: 0

README

gograte

Example migration repo using psql and go only

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PSQLArgs

func PSQLArgs(up bool, profile string) ([]string, error)

PSQLArgs takes a slice of DDL files to be executed and builds a sequence of command line arguments using the appropriate flags psql needs to execute files. The arguments returned for psql are as follows:

-w flag is set to never prompt for a password as we are running this as a script

-d flag sets the database connection using a Connection URI string.

-f flag is sent before each file to tell it to process the file

Types

type ConfigCueFilePaths

type ConfigCueFilePaths struct {
	// Input defines the list of paths for files to be taken as input for CUE
	Input []string
	// Output defines the path for the JSON output of CUE
	Output string
}

ConfigCueFilePaths defines the paths for config files processed through CUE.

func CUEPaths

func CUEPaths(profile string) ConfigCueFilePaths

CUEPaths returns the ConfigCueFilePaths. Paths are relative to the project root.

type ConfigFile

type ConfigFile struct {
	Config struct {
		Database struct {
			Host       string `json:"host"`
			Port       int    `json:"port"`
			Name       string `json:"name"`
			User       string `json:"user"`
			Password   string `json:"password"`
			SearchPath string `json:"searchPath"`
		} `json:"database"`
		MigrationScriptsDir string `json:"migrationScriptsDir"`
	} `json:"config"`
}

ConfigFile defines the configuration file.

func NewConfigFile

func NewConfigFile(configFilePath string) (ConfigFile, error)

NewConfigFile initializes a Config struct from a JSON file at a predetermined file path (path is relative to project root)

Local: ./config/local.json

type PostgreSQLDSN

type PostgreSQLDSN struct {
	Host       string
	Port       int
	DBName     string
	SearchPath string
	User       string
	Password   string
}

PostgreSQLDSN is a PostgreSQL datasource name

func (PostgreSQLDSN) ConnectionURI

func (dsn PostgreSQLDSN) ConnectionURI() string

ConnectionURI returns a formatted PostgreSQL datasource "Keyword/Value Connection String" The general form for a connection URI is: postgresql://[userspec@][hostspec][/dbname][?paramspec] where userspec is

user[:password]

and hostspec is:

[host][:port][,...]

and paramspec is:

name=value[&...]

The URI scheme designator can be either postgresql:// or postgres://. Each of the remaining URI parts is optional. The following examples illustrate valid URI syntax:

postgresql://
postgresql://localhost
postgresql://localhost:5433
postgresql://localhost/mydb
postgresql://user@localhost
postgresql://user:secret@localhost
postgresql://other@localhost/otherdb?connect_timeout=10&application_name=myapp
postgresql://host1:123,host2:456/somedb?target_session_attrs=any&application_name=myapp

func (PostgreSQLDSN) KeywordValueConnectionString

func (dsn PostgreSQLDSN) KeywordValueConnectionString() string

KeywordValueConnectionString returns a formatted PostgreSQL datasource "Keyword/Value Connection String"

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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