go-pgrun

command module
v0.0.0-...-0408917 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2021 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

GO-PGRUN

Simple CLI tool to run sql commands from files against postgresql used for migrations

Command line flags:

  -C string
        Path to config file (default "config.json")
  -D string
        Path to data file
  -V value
        Set value. Must be in format -V name,value

-V can be used multiple times like

go-pgrun -D commands.sql -V dbname,dev -V needver,0.1.4

Simple config.json:

{
    "user" : "postgres",
    "password" : "password",
    "database" : "postgres"
}

Simple data file:

\val dbname devDb
\val user devUser
\val ver 0.1.1

\os windows
\val collate Russian_Russia.1251
\os linux
\val collate ru-Ru.utf8
\os

DROP DATABASE IF EXISTS ##dbname##;
\go

CREATE DATABASE ##dbname##
    WITH 
    OWNER = ##user##
    ENCODING = 'UTF8'
    LC_COLLATE = '##collate##' 
    LC_CTYPE = '##collate##'
    TABLESPACE = pg_default
    CONNECTION LIMIT = -1
    TEMPLATE template0;
\go

--reconnect to db
\db ##dbname##

--check for db version
--breaks execution if not equal
--version is stored as comment on database 
--\needVer ##ver##

\os windows
COMMENT ON DATABASE ##dbname## IS '##ver##';
\os linux
COMMENT ON DATABASE ##dbname## IS 'im on linux';
\os

Versions must follow SemVer.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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