rnubel / pgmgr Goto Github PK
View Code? Open in Web Editor NEWPostgres Database Manager for Go web apps
License: MIT License
Postgres Database Manager for Go web apps
License: MIT License
Currently each time a migration is applied and unless pgmgr dump
is executed there's no dump or structure file that gets generated.
This feature would create a structure only sql file each time a migration is ran and can be toggled on and off via the config file through the setting:
{
"db-structure": "path/to/structure/"
}
By default, the structure is not generated unless this part of the configuration is specified.
Right now (correct me if I am wrong) but it's usage is tied to the CLI right?
What're your thoughts on allowing the package to be used in a code?
I have postgres running in docker, when I try run pgmgr db create, got error: Error: exec: "createdb": executable file not found in $PATH
How I can fix this, and work with docker?
{
"host": "localhost",
"port": 5432,
"username": "postgres",
"password": "postgres",
"database": "local",
"migration-table": "public.schema_migrations",
"migration-folder": "db/migrations",
"dump-file": "etc/db/dump.sql",
"column-type": "string",
"format": "unix"
}
> pgmgr db create
createdb: could not connect to database template1: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Error: exit status 1
{
"host": "192.168.56.2",
"port": 5432,
"username": "vagrant",
"password": "vagrant",
"database": "goscratch",
"sslmode": "disable",
"migration-table": "public.schema_migrations",
"migration-folder": "migrations",
"dump-file": "migrations/dump.sql",
"column-type": "integer",
"format": "unix"
}
When attempting pgmgr db create
it fails because the config is not passed into the createdb command correctly.
https://github.com/rnubel/pgmgr/blob/master/pgmgr/pgmgr.go#L48
passing in something manually, works and then the rest of the commands (migrate function correctly)
createdb -h 192.168.56.2 -U vagrant -O vagrant goscratch
> createbd -V
createdb (PostgreSQL) 9.6.3
We are using this tool heavily in our project in development.
We need to connect to heroku-postgres. It requires SSL. I checked that sslmode=require functionality is a TODO. But for now, what could be the way to connect, until this is implemented?
Thanks!
This issue is for documenting the fix to the above error -- if you are trying to install pgmgr from a folder where Go module support is not found, you may see this error as the cli dependency was not stable. In #46, I moved pgmgr to use Go modules to lock down its dependencies, so the fix for this is to install the tool with modules turned on:
GO111MODULE=on go get github.com/rnubel/pgmgr
This workaround should become unnecessary once Go changes its default setting for GO11MODULE to on
, which should be in Go 1.14 or so.
Currently pgmgr
looks for a .pgmgr.json
file to set the package and database configuration.
Although we are able to override the default search path via PGMGR_CONFIG_FILE
I propose that
the .pgmgr.json
configuration will only have configuration attributes specific to the package commands.
So instead of this configuration (which is db config related):
{
"host": "localhost",
"port": 5432,
"username": "test",
"password": "test",
"database": "testdb",
"migration-table": "public.schema_migrations",
"migration-folder": "db/migrate",
"dump-file": "db/dump.sql",
"column-type": "integer",
"format": "unix",
"seed-tables": [ "foos", "bars" ]
}
It would be better if we have this file configure where the database configuration resides and toggle the different configurations via env vars that has a default to development.
{
"dbconfig-folder": "config/db.conf.json",
"migration-folder": "db/migrate",
"dump-file": "db/dump.sql"
}
This would still work well with the current configuration that allows overrides with the environmental variables.
DEPRECATED Action signature. Must be
cli.ActionFunc
. This is an error in the application. Please contact the distributor of this application if this is not you. See https://github.com/codegangsta/cli/blob/master/CHANGELOG.md#deprecated-cli-app-action-signature
It doesn't look like the password for the database gets parsed by func (config *Config) overrideFromURL()
whereas the documentation seems like it would. Is there a reason for that?
I can make a PR if not, otherwise I might be missing your intention?
Was using pgmgr yesterday with the connection string in the environment, now it doesn't seem to recognize the user in a CI environment. I'll double check to see if I'm doing anything different, but I do not think I am.
PGMGR_URL='postgres://postgres@database:5432/postgres?sslmode=disable' pgmgr db migrate
Error during migration: pq: role "root" does not exist`
schema_migrations table which is getting created by pgmgr is not getting a primary key we want every table to have a primary as good standard of creation.
Is it possible to convert this into a library?
To remove development and deployment/CI complexity, it would be nice to have a library version.
Is there a reason why you duplicate the standards postgres environment variables into the PGMGR_*
ones ?
If they're no specific reason, I think you should reuse the ones from postgres, it would be more convenient for the user.
I'd like to implement something that provides a feature similar to ActiveRecord::Migration#disable_ddl_transaction!. Mostly so I can run CREATE INDEX CONCURRENTLY ...
.
I've currently got two ideas for how this could happen:
-- transaction: false
or such.<ts>_<name>.notx.up.sql
or such.Option 1 reminds me of tools I didn't like using, and means we'd have to read the migration and do some juggling of the contents before we could run them.
Option 2 is simpler, but if another option comes along, suddenly we gotta figure out how to encode that into the filename as well. I can't think of any other useful options, tho.
You into either of these? Or got any other ideas?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.