Code Monkey home page Code Monkey logo

pgpm's People

Contributors

megaponchic avatar ulevin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

valdelmeglio

pgpm's Issues

Field "ddl_change_user" contains the owner of _pgpm - should be the user, who issued the command

It's enough to use session_user instead of current_user as default for this column.
I could prove that by hacking "ALTER TABLE ... ALTER COLUMN ... SET DEFAULT session_user" - and it worked.

Consider the following:
flehmann=# create function pgpm_test() returns text as $$select current_user::text$$ security definer language sql;
CREATE FUNCTION
flehmann=# select pgpm_test();
--> flehmann
flehmann=# alter function pgpm_test() owner to postgres;
ALTER FUNCTION
flehmann=# select pgpm_test();
--> postgres

flehmann=# create function pgpm_test1() returns text as $$select session_user::text$$ security definer language sql;
CREATE FUNCTION
flehmann=# select pgpm_test1();
--> flehmann
flehmann=# alter function pgpm_test1() owner to postgres;
ALTER FUNCTION
flehmann=# select pgpm_test1();
--> flehmann

add functionality to send emails

make pgpm also send emails if it is set in general config file.
Configuration for SMTP:

"email": {
        "type": "SMTP",
        "credentials": {
            "username": "user",
            "password": "pass"
        },
        "host": "smtp.example.com",
        "port": 465,
        "from": "[email protected]",
        "to": "[email protected]",
        "subject": "Subject",
        "body": "Body"
    }

add --force-table-cascade and --force-inter-schema-cascade parameters

add support for two parameters:

  1. --force-table-cascade will (when dropping schema objects) drop dependent table objects (like columns).
    Example: table a has column c with type t. When dropping type t with cascade column c will be dropped as well.
    We don't want that by default (as table evolutions are managed differently from functions/types changes).
  2. --force-inter-schema-cascade will (when dropping schema objects) drop dependent objects in other schema (not table related like columns, for those you will need to use --force-table-cascade as well.

Add table auditing

Add functions to pgpm that will start/stop auditing changes to specified tables

"pgpm install <connect_string> -u xxx " does not work

The option "-u" seems to be broken, because without it i can install. The error message is:
...
2015-08-17 12:38:15,579 - pgpm.deploy - INFO - scripts/functions/_find_schema.sql
Traceback (most recent call last):
File "/usr/local/bin/pgpm", line 11, in
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/pgpm/deploy.py", line 783, in main
install_manager(arguments)
File "/usr/local/lib/python2.7/dist-packages/pgpm/deploy.py", line 364, in install_manager
cur.execute(GRANT_DEFAULT_USAGE_PRIVILEGES.format(_variables.PGPM_SCHEMA_NAME, ', '.join(user_roles)))
psycopg2.ProgrammingError: schema "_pgpm" does not exist

Make pgpm install itself in `_pgpm` schema

There should be pgpm install command that must be run before pgpm deploy can be used.
Installation procedure will:

  • create _pgpm schema in the db unless it was created already.
  • if table did not exist before, create table tracked_schemas that will include info from config.json (e.g. name, current version, type, dependencies)

add support for additional config files

This should be supported

pgpm deploy <connection_string> --add-config file_name

it will add aditional config file on top of config.json and will override config.json's settings

be able to choose to what dbs to deploy when using set command

format of the set of db connection strings will understand one more attribute: unique_name (could be the same as dbname):

[
    {
        "host": "HOST_NAME",
        "dbname": "DBNAME",
        "port": PORT,
        "environment": "ENVIRONMENT_NAME",
        "unique_name": "UNIQUE NAME ALIAS"
    }
]

allow same ddl-script name in different repositories

Sometimes fo rone feature i have to do ddl-changes in 2 (or more) schemas/repos. So my ddl-scripts naturally are named the same (in my case edarling_cid_tracking/ddl/acs_162_flehmann.sql and edarling_dwh_data/ddl/acs_162_flehmann.sql)
When deploying the second, I get "ddl/acs_162_flehmann.sql is not executed for schema edarling_dwh_data as it has already been executed before."
You would probably just add a column "package" to _pgpm.table_evolutions_log and add the package as parameter to _pgpm._is_table_ddl_executed(p_file_name text)

Add dependancy management

Dependency entry in config.json file will be parsed. Concept is somewhat similar to https://docs.npmjs.com/files/package.json#dependencies

  • version numbers must follow a modified semver. The difference is that instead of dots version digits should be separated with _ sign (. is not allowed character for schema names)
  • version notation can support:
    • exact version number either in a format 1_2_3 or 01_02_03 (latter format is for formatting purposes)
    • x notation like 01_02_XX or 01_02_xx or 1_2_X or 1_2_x
    • comparison operators like >01_02_03 or <2
    • x for any latest version of package
  • package name must comply with naming conventions of postgres, exist as schema and be trackable by pgpm in order to satisfy dependancy

Example:

{ "dependencies" :
  { "foo" : "1_2_3"
  , "bar" : ">=01_02_03"
  , "baz" : ">01_02_XX"
  , "boo" : "1_2_x"
  , "qux" : "<2"
  , "thr" : "x"
  }
}

version Issue

pgpm is not accepting version that contain characters.
Example:
"version" : "11_07_00", -> Works correctly
"version" : "11_v_00", -> Throws an error

Change --user bahaviour

rename --user flag to --usage flag and use --user flag as a user that connects to DB when used set option.

At the same time if user is not specified, os user must be used for connection attempt and warning message output

feature poposal: ALTER <object> OWNER TO <owner_role>

After we deployed one new schema with "-o " option, but connecting as one personal (super-) user, only the schema is owned by the , but all the objects, in this case types and functions, are owned by the one personal (super-) user.
This is not what we expect and want. Please make the owner-role owner of all objects.
The connecting (super-) user should still appear in the "_pgpm" deployment logs, but not in the real structures.
Note, that the person, who executes a pgpm deployment will probably have to be superuser, but may not have the credentials of the owner-role. As far as i know, there is no "switch user" in postgres and if there was, we wouldn't want to use it here, because we want to identify the individual user in the deployment logs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.