dbcc - Database check & create tool.
This is a database superuser agent which
- listens http port
- gets authorized requests with
name - check if requested database
name& usernameexists and create them otherwise.
Only postgresql database supported now.
$ go build
If you need cross platform build with gox, run
$ make buildall
With mock database:
$ go test
With real database server:
# set connection vars in ENV and run
$ DBCC_TEST_DB=1 PGUSER=op go test
$ gosu postgres ./dbcc --key=YOUR_SECRET_KEY
or
$ APP_KEY=YOUR_SECRET_KEY gosu postgres ./dbcc
curl "http://$DB_HOST:8080/?key=YOUR_SECRET_KEY&name=operator&pass=operator_pass[&tmpl=template]"
Will do the following:
- if user
operatordoes not exists then create it with passwordoperator_pass - if database
operatordoes not exists then create it with owneroperatorand templatetemplate(default template1)
and return
OK: 00if nothing was doneOK: 10if db created (user exists)OK: 11if user & db created
The MIT License (MIT)
Copyright (c) 2015 Alexey Kovrizhkin lekovr@gmail.com
