Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native driver option does not work #8

Closed
Crocmagnon opened this issue Feb 2, 2016 · 30 comments
Closed

Native driver option does not work #8

Crocmagnon opened this issue Feb 2, 2016 · 30 comments

Comments

@Crocmagnon
Copy link

Crocmagnon commented Feb 2, 2016

Hello,
I'm trying to deploy on Heroku but it complains that SSL is not enabled. I tried activate "native: true" in my database.json file :

{
    "prod": {
        "ENV": "DATABASE_URL",
        "native": true
    },
    "dev": {
        "ENV": "DATABASE_URL"
    }
}

I had no luck. By slightly changing the code in index.js :

exports.connect = function(config, intern, callback) {

    internals = intern;

    log = intern.mod.log;
    type = intern.mod.type;
    console.log("config", config); // Added a console.log
    if (config.native) { pg = pg.native; }
    var db = config.db || new pg.Client(config);
    callback(null, new PgDriver(db, config.schema, intern));
};

We can see that config doesn't contain a native property, so it never enters the condition.

@Crocmagnon Crocmagnon changed the title Not using native driver Not using native driver with URL Feb 3, 2016
@Crocmagnon Crocmagnon changed the title Not using native driver with URL Not using native driver with environment URL Feb 3, 2016
@Crocmagnon Crocmagnon changed the title Not using native driver with environment URL Can't connect to SSL database Feb 3, 2016
@wzrdtales
Copy link
Member

pg-native is considered optional, you need to install it in your local project first.

If you installed the pg driver globally then you need to do

npm install -g pg-native

if local then

npm install pg-native

I think we need to add this to the docs, seems like we do not have any informations about the native driver option of pg.

The default installation by default of pg-native was removed as it is not needed by everyone and also caused trouble here:
db-migrate/node-db-migrate#286

@wzrdtales wzrdtales changed the title Can't connect to SSL database Native driver option does not work Feb 3, 2016
@wzrdtales
Copy link
Member

Added task here:
db-migrate/english-docs#5

@Crocmagnon
Copy link
Author

The module is already installed, but still the native option is not passed.
I have the feeling that if a "DATABASE_URL" environment variable is set, it
overrides any setting we may have set, even the "-e env" option when
running.

Le mercredi 3 février 2016, Tobias Gurtzick [email protected] a
écrit :

pg-native is considered optional, you need to install it in your local
project first.

If you installed the pg driver globally then you need to do

npm install -g pg-native

if local then

npm install pg-native

I think we need to add this to the docs, seems like we do not have any
informations about the native driver option of pg.

The default installation by default of pg-native was removed as it is not
needed by everyone and also caused trouble here:
db-migrate/node-db-migrate#286
db-migrate/node-db-migrate#286


Reply to this email directly or view it on GitHub
#8 (comment).

@wzrdtales
Copy link
Member

Could you try this locally again and maybe post the verbose runs?

I just tried it with a global installed driver:

Before installing the pg-native module:

db-migrate down
[INFO] Defaulting to running 1 down migration.
[ERROR] Error: Cannot find module 'pg-native'
    at Function.Module._resolveFilename (module.js:326:15)
    at Function.Module._load (module.js:277:25)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/home/tobi/.nvm/versions/node/v4.2.6/lib/node_modules/db-migrate-pg/node_modules/pg/lib/native/index.js:1:76)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at null.<anonymous> (/home/tobi/.nvm/versions/node/v4.2.6/lib/node_modules/db-migrate-pg/node_modules/pg/lib/index.js:78:36)
    at Object.exports.connect (/home/tobi/.nvm/versions/node/v4.2.6/lib/node_modules/db-migrate-pg/index.js:493:33)
    at connect (/home/tobi/.nvm/versions/node/v4.2.6/lib/node_modules/db-migrate/lib/driver/index.js:105:12)
    at Object.exports.connect (/home/tobi/.nvm/versions/node/v4.2.6/lib/node_modules/db-migrate/lib/driver/index.js:146:5)
    at Object.exports.connect (/home/tobi/.nvm/versions/node/v4.2.6/lib/node_modules/db-migrate/connect.js:17:10)
    at executeDown (/home/tobi/.nvm/versions/node/v4.2.6/lib/node_modules/db-migrate/api.js:717:9)
    at run (/home/tobi/.nvm/versions/node/v4.2.6/lib/node_modules/db-migrate/api.js:924:9)
    at Object.dbmigrate.run (/home/tobi/.nvm/versions/node/v4.2.6/lib/node_modules/db-migrate/api.js:358:5)
    at /home/tobi/.nvm/versions/node/v4.2.6/lib/node_modules/db-migrate/bin/db-migrate:35:11
    at /home/tobi/.nvm/versions/node/v4.2.6/lib/node_modules/db-migrate/node_modules/resolve/lib/async.js:46:14
    at process (/home/tobi/.nvm/versions/node/v4.2.6/lib/node_modules/db-migrate/node_modules/resolve/lib/async.js:173:43)

After it was installed:

[tobi:test]$ npm install -g pg-native

> [email protected] install /home/tobi/.nvm/versions/node/v4.2.6/lib/node_modules/pg-native/node_modules/libpq
> node-gyp rebuild

make: Entering directory '/home/tobi/.nvm/versions/node/v4.2.6/lib/node_modules/pg-native/node_modules/libpq/build'
  CXX(target) Release/obj.target/addon/src/connection.o
  CXX(target) Release/obj.target/addon/src/connect-async-worker.o
  CXX(target) Release/obj.target/addon/src/addon.o
  SOLINK_MODULE(target) Release/obj.target/addon.node
  COPY Release/addon.node
make: Leaving directory '/home/tobi/.nvm/versions/node/v4.2.6/lib/node_modules/pg-native/node_modules/libpq/build'
[email protected] /home/tobi/.nvm/versions/node/v4.2.6/lib/node_modules/pg-native
├── [email protected]
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected])
[tobi:test]$ db-migrate down
[INFO] Defaulting to running 1 down migration.
[INFO] No migrations to run
[INFO] Done

@wzrdtales
Copy link
Member

The require of the native driver works though, also tested with a local driver just now. Seems like something else does not work for you.
Lets figure out what.

@Crocmagnon
Copy link
Author

Config

I don't think this applies, the pg-native driver seems to be working fine if I require it from code.
I assume it's something different, so first things first, here's my config :

  • OS X 10.11.3 (El Capitan up to date)
  • node and npm installed with brew
  • Using dotenv

Also, here are my dependencies :

{
    "dependencies": {
        "body-parser": "^1.14.2",
        "db-migrate": "^0.10.0-beta.10",
        "db-migrate-pg": "^0.1.8",
        "dotenv": "^2.0.0",
        "express": "^4.13.4",
        "express-validator": "^2.19.0",
        "pg": "^4.4.4",
        "pg-native": "^1.10.0",
        "supertest": "^1.1.0"
    }
}

First try

I tried to remove my DATABASE_URL environment variable and modify my database.json :

{
    "prod": {
        "native": true,
        "ENV": "DATABASE_URL"
    },
    "dev": {
        "ENV": "DATABASE_URL"
    },
    "temp": {
        "native": true,
        "driver": "pg",
        "user": {"ENV": "PROD_DB_USER"},
        "host": {"ENV": "PROD_DB_HOST"},
        "database": {"ENV": "PROD_DB_NAME"},
        "password": {"ENV": "PROD_DB_PASS"}
    }
}

And run it with db-migrate up -e temp, though it still complains :

[ERROR] TypeError: Parameter 'url' must be a string, not undefined
    at Url.parse (url.js:90:11)
    at Object.urlParse [as parse] (url.js:84:5)
    at module.exports (/Users/gaugendre/Projects/archery/api/node_modules/parse-database-url/lib/parse-database-url.js:16:23)
    at Object.exports.loadObject (/Users/gaugendre/Projects/archery/api/node_modules/db-migrate/lib/config.js:67:18)
    at Object.exports.loadFile (/Users/gaugendre/Projects/archery/api/node_modules/db-migrate/lib/config.js:59:18)
    at loadConfig (/Users/gaugendre/Projects/archery/api/node_modules/db-migrate/api.js:508:18)
    at Object.dbmigrate (/Users/gaugendre/Projects/archery/api/node_modules/db-migrate/api.js:67:17)
    at Object.module.exports.getInstance (/Users/gaugendre/Projects/archery/api/node_modules/db-migrate/index.js:56:10)
    at /usr/local/lib/node_modules/db-migrate/bin/db-migrate:34:23
    at /usr/local/lib/node_modules/db-migrate/node_modules/resolve/lib/async.js:44:21
    at ondir (/usr/local/lib/node_modules/db-migrate/node_modules/resolve/lib/async.js:187:31)
    at onex (/usr/local/lib/node_modules/db-migrate/node_modules/resolve/lib/async.js:93:22)
    at /usr/local/lib/node_modules/db-migrate/node_modules/resolve/lib/async.js:24:18
    at FSReqWrap.oncomplete (fs.js:82:15)

Second try

I suspected it tried to load the dev environment even if I specified other in command line, then I try with this database.json :

{
    "temp": {
        "native": true,
        "driver": "pg",
        "user": {"ENV": "PROD_DB_USER"},
        "host": {"ENV": "PROD_DB_HOST"},
        "database": {"ENV": "PROD_DB_NAME"},
        "password": {"ENV": "PROD_DB_PASS"}
    }
}

And still db-migrate up -e temp, I get this :

config { native: true,
  driver: 'pg',
  user: 'WWW',
  host: 'ec2-54-195-248-72.eu-west-1.compute.amazonaws.com',
  database: 'XXX',
  password: 'YYY' }
[ERROR] Error: FATAL:  password authentication failed for user "WWW"
FATAL:  no pg_hba.conf entry for host "87.91.101.94", user "WWW", database "XXX", SSL off

    at Error (native)

The first lines are from my console.log, and we can see that it loads pg-native, but doesn't seem to activate SSL.

Third try

Then, I also tried something different : I tried to use this database.json:

{
    "temp": {
       "ENV": "DB_CONNECTION"
    }
}

with this .env file:

DB_CONNECTION=postgres://WWW:[email protected]/XXX?ssl=true

And then it finally works ! But I don't have any way to modify my DATABASE_URL environment variable in Heroku: it may change any time because of the free tier I'm using.

Tried to remove the ssl=true from the URL and put it in database.json, not loaded.

Conclusion

I see many problems here (don't hesitate to tell me if I'm wrong) :

  • db-migrate always uses dev environment if it exists in database.json
  • "native": true doesn't activate SSL though it loads pg-native
  • ?ssl=true at the end of the database url activates ssl, but we need a way to specify it in database.json

@Crocmagnon
Copy link
Author

Also, don't hesitate to tell me if you really need me to run the tests you asked in your comment !

@Crocmagnon
Copy link
Author

I also suspect that if DATABASE_URL is set, then it overrides any config from database.json, even if selecting other environment with -e env.

@wzrdtales
Copy link
Member

I will take a look in the evening (in about 6 hours) again, and try to reproduce this.

@Crocmagnon
Copy link
Author

Thanks ! Just out of curiosity, in which timezone are you located ?

@wzrdtales
Copy link
Member

GMT+1

@Crocmagnon
Copy link
Author

Ok nice, so we're synced ;)

@wzrdtales
Copy link
Member

  • db-migrate always uses dev environment if it exists in database.json
    It uses by default dev that is true, but only as long as you don't specify any environment to use or you have set the configuration variable default which allows you to define the default environment to use
  • "native": true doesn't activate SSL though it loads pg-native
    It shouldn't, native doesn't mean SSL, it really just means native. And native comes from the native language that the pg-native driver uses (c++). This is just a faster driver, but not automatically SSL.
  • ?ssl=true at the end of the database url activates ssl, but we need a way to specify it in database.json
    Going to take a look at this, may this is really missing right now.

@wzrdtales
Copy link
Member

The thing about the DATABASE_URL is possibly true, going to check this out next.

@wzrdtales
Copy link
Member

I'm away now again, but here is the status.

I got the answer from this test here:

https://github.com/brianc/node-postgres/blob/35e5567f86774f808c2a8518dd312b8aa3586693/test/integration/client/ssl-tests.js

I modified your configuration examples for this, you can configure it like this:

{
    "temp": {
        "native": true,
        "driver": "pg",
        "ssl": true,
        "user": {"ENV": "PROD_DB_USER"},
        "host": {"ENV": "PROD_DB_HOST"},
        "database": {"ENV": "PROD_DB_NAME"},
        "password": {"ENV": "PROD_DB_PASS"}
    }
}

If you want to force your client to use ssl, you need this:

{
    "temp": {
        "native": true,
        "driver": "pg",
        "ssl": {
          "rejectUnauthorized": false
        },
        "user": {"ENV": "PROD_DB_USER"},
        "host": {"ENV": "PROD_DB_HOST"},
        "database": {"ENV": "PROD_DB_NAME"},
        "password": {"ENV": "PROD_DB_PASS"}
    }
}

You can still use the native option, as it can give you a performance boost. But this you need to evaluate yourself.

I will be back in about 4 hours.

@wzrdtales
Copy link
Member

Ok, I'm back.

To explain a bit about the configs, whenever you're not sure if some configuration options are available on a driver, you can consult the used driver itself. db-migrate passes the configuration object to the database driver and thus all driver options are in most, if not any cases available to you.

And finally about the DATABASE_URL thing: Yes, this is currently the case:

https://github.com/db-migrate/node-db-migrate/blob/master/api.js#L503

I will open a task for this to change this behavior as this definitely an unexpected behavior. Thank you for reporting this!

@Crocmagnon
Copy link
Author

Ok, so finally, how do I use both an URL provided in environment variable and SSL ?

I tried this :

{
    "prod": {
        "ssl": true,
        "ENV": "DB_CONNECTION"
    }
}

But the "ssl": true doesn't appear it in the config object coming to the driver and then it fails connecting.
I also tried :

{
    "prod": {
        "ssl": true,
        "url": {"ENV": "DB_CONNECTION"}
    }
}

But this time the url is not recognized as the connection url.

@wzrdtales
Copy link
Member

if you use an url you would also define this within the url. Either you use an url, or you use the configuration object, but not both. The attempt you started before was already the way how you're doing this with an url:

DB_CONNECTION=postgres://WWW:[email protected]/XXX?ssl=true

So if you're using an url, you put also all options into the url, this is what it is intended to do.

@wzrdtales
Copy link
Member

The same goes for the native option, that would also be part of the url:

DB_CONNECTION=postgres://WWW:[email protected]/XXX?ssl=true&native=true

So you need to decide if you want to use the url, or if you want to use the configuration object. That totally depends on what you need and what is actually easier to configure.

@Crocmagnon
Copy link
Author

Ok, I understand what you mean. The fact is I'm deploying on Heroku, and I'm provided with a DATABASE_URL environment variable which I can't change (either its name or content) because my database is susceptible to be moved to another host. So I basically can't add this option to the URL, nor can't I create another environment variable since it would break as soon as Heroku would migrate my DB.

Wouldn't it be possible to have an url provided by environment variable but still adding some options ? The parameters given in the object would override the ones from the URL (or not, depending on your choice, or maybe a config option).

@wzrdtales
Copy link
Member

To also give you some examples:

If you want to use a database uri:

{
  "default": "prod",
  "prod": { "ENV": "your_environment_variable_with_your_uri" }
}

If you want to use multiple environment variables:

{
    "default": "temp",
    "temp": {
        "native": true,
        "driver": "pg",
        "ssl": true,
        "user": {"ENV": "PROD_DB_USER"},
        "host": {"ENV": "PROD_DB_HOST"},
        "database": {"ENV": "PROD_DB_NAME"},
        "password": {"ENV": "PROD_DB_PASS"}
    }
}

Hope that answers your question.

@wzrdtales
Copy link
Member

Ok, I see your use case here, also that I think that heroku should already append ssl to the uri if they only allow ssl though.

But yes adding parameters may be wished as you would not be able to use the native driver version for example.

I would need to answer some questions first before considering a solution, that would be for example:
Which property overwrites which other property:

  • The configuration objects properties the uri ones or the other way around?
  • Should we display a warning when db-migrate overwrites a parameter as this is an unexpected behavior?
  • Or should we add a configuration section that is called something like overwrite?

Need to take a look at this tomorrow again.

@wzrdtales
Copy link
Member

Item opened here: db-migrate/node-db-migrate#349

@Crocmagnon
Copy link
Author

I totally agree with that, they should append their uri with ssl...

I think that there might be some cases where we're given a URI and can't do very much about it, so I'd say that the object properties should overrite URI properties if they're defined in both. But, as you point out, it may be an unexpected behavior, so maybe a warning but with a configuration option that would say "i know what I'm doing, override these params".
Maybe this config option could provide an override "direction" (I want to override URI params with object, or I want URI to override my object).

To sum up :

  • Default to "object overrides URI"
  • Warning
  • Config option that mutes warning and provide override direction

@wzrdtales
Copy link
Member

Ok, new Morning, fresh mind, here are my thoughts:

As the extending just applies to urls, we should also only apply this changes to this scope. That would mean the following changes:

Configuration Examples:

With environment variable:

{
  "default": "pg",
  "pg": { 
    "ENV": "DATABASE_URL",
    "addIfNotExists": {
      "ssl": true
    },
    "overwrite": {
      "native": true
    }
  }
}

Without environment variable:

{
  "default": "pg",
  "pg": { 
    "url": "postgres://postgres:password@myserver/mydb?native=false",
    "addIfNotExists": {
      "ssl": true
    },
    "overwrite": {
      "native": true
    }
  }
}

In this case th native property would be true afterwards.

To avoid confusion also this will be supported:

{
  "default": "pg",
  "pg": { 
    "url": { 
      "ENV": "DATABASE_URL",
      "addIfNotExists": {
        "ssl": true
      },
      "overwrite": {
        "native": true
      }
    }
  }
}

db-migrate also should throw with the error duplicate addIfNot property in database.json in env pg if a user does this:

{
  "default": "pg",
  "pg": { 
    "url": { 
      "ENV": "DATABASE_URL",
      "addIfNotExists": {
        "ssl": true
      },
      "overwrite": {
        "native": true
      }
    }
  }
}

@Crocmagnon
Copy link
Author

Seems fair! I don't have anything to add, this seems a perfectly valid implementation to solve this issue.

@wzrdtales
Copy link
Member

@Crocmagnon I guess this feature would be important for you? If not I would like to move that a bit to the back, all informations are already here: db-migrate/node-db-migrate#349 and also tests that should pass are available, I would work then on some other things right now if it is not needed asap.

@Crocmagnon
Copy link
Author

Don't worry, it's not urgent. I can work without it for a while but I'll have to deploy an app in a few months and I'd like to automate migrations 😃

@wzrdtales
Copy link
Member

@Crocmagnon Alright, I will come back on this at some later time. If it gets urgent for some reason earlier let me know, you can also naturally always go for a PR, those are always welcome :)

I expect that I will lay hands on this in two weeks again.

@Crocmagnon
Copy link
Author

Ok, thank you for your time !
I'll let you know if I need it quicker.

Le vendredi 5 février 2016, Tobias Gurtzick [email protected] a
écrit :

@Crocmagnon https://github.com/Crocmagnon Alright, I will come back on
this at some later time. If it gets urgent for some reason earlier let me
know, you can also naturally always go for a PR, those are always welcome :)

I expect that I will lay hands on this in two weeks again.


Reply to this email directly or view it on GitHub
#8 (comment).

wzrdtales added a commit to db-migrate/node-db-migrate that referenced this issue Aug 13, 2017
This allows to parse a url from an url property and as well to overwrite and extend
variables as needed.
To pass in url as normal value an object is needed like the following: { url: { value: "http://example.com } }.

Fixes #349
Fixes db-migrate/pg#8
Fixes #488
Fixes #463
wzrdtales added a commit to db-migrate/node-db-migrate that referenced this issue Aug 13, 2017
This allows to parse a url from an url property and as well to overwrite and extend
variables as needed.
To pass in url as normal value an object is needed like the following: { url: { value: "http://example.com } }.

Fixes #349
Fixes db-migrate/pg#8
Fixes #488
Fixes #463
RandomSeeded added a commit to blend/node-db-migrate that referenced this issue May 29, 2018
* cs fixes

* add concepting to comments

* fix driver inclusion

* remove sqlite dependency, add sqlite to devdependencies and outsource driver

* remove unnecessary files

* remove mongodb dependency, outsource mongodb driver

* Bump sqlite3 package version to fix issue with node 4.0.0

* Bump sqlite3 package version to fix issue with node 4.0.0

* add node version 4.0, remove iojs allowed build failures

* remove mysql dependency and add to dev for testing purposes

* fix index_test tests

* change base test to extern base

* fix index test

* remove last driver dependencies

resolves db-migrate#227

* add pg to dev dependencies

* ?

* updated fixed pg driver

* add error message to executeDB and handle callback

* return error message if available or the object/message directly passed through

* fix some cs issues

* add missing nosql methods to interface

* do not strip private functions from driver

removed unnecessary entries from migrator interface
do not strip any `_function` unless it is explicitly defined via exclude

* change config to internal scope

* fix test for new internal config

* fix last details to move config i into internal scope

* remove debug message

* remove es5 from jshint rules, fix one cs

*  add rules to jshint

* fix some cs issues and adjust rules

* adjust some settings and add jscs already

* [cs] fixed some issues and do some cleanup

* update lab

* update dependency and check

* add 4.1 to travis ci

* change couple of templates

* update sql templates

* add undo seed function to api

* fix bug on up/down of seeders

* add reset method and limit down methods of seeds

* add dummy calls to linked seeders and migrations

* link to read the docs and remove readme documentation

* 0.10.0-beta.1

* remove the badge ending from the documentation url

* make entry in readme more clear to be also a user manual

* Extend startup with logging and failure handling on 0.9.x versions

Before this patch users may ran into a local installation older than 0.9.x, this patch
ensures that the version is compatible to be preffered over the global version. If the
local version is to old (<0.10.0) the global version will be used instead. If this is
the case a warn message gets displayed to the user.

Additionally added informational logging within the verbose mode if a local version gets
preferred.

solves db-migrate#317

* 0.10.0-beta.2

* add lts node.js version to travis tests

* Resolve driver from local projects

Fixes db-migrate#318

* use synchronized variant of resolve for drivers

* 0.10.0-beta.3

* fix sql templates to work with 0.10.x again

* ignore on init formatting

* 0.10.0-beta.4

* Support setting default environment via ENV variable.

* Support setting default environment via ENV variable.

* coffeescript template refactory

coffeescript template refactory

by default coffeescript always returns the last line/variable, so there is no need to use the ~return~ keyword, there is not need for ; also.

* add scope logging

* [bugfix] internal linking causes infinite loop

fixes db-migrate#329

* add scope logging

* [bugfix] internal linking causes infinite loop

fixes db-migrate#329

* coffeescript template refactory

coffeescript template refactory

by default coffeescript always returns the last line/variable, so there is no need to use the ~return~ keyword, there is not need for ; also.

* 0.10.0-beta.5

* remove debug message

* 0.10.0-beta.6

* allow configuration through options object

* adjust test

* add direct execution of seeders and migrator links

* Fix config file setting.

* update parse db-url to 0.3.0

Introduces mongodb uri support

* update some dependencies

* fix(migration):

A promise is not properly identified and returning an empty resolve ends up in
db-migrate hanging up forever.

Fixes db-migrate#343

* fix(api): callback not called on run

If db-mgirate is run via any run method (except directly from console), the callback was not available
to the migration functions anymore.

* fix(api): callback called twice

Revert the change to add the callback if it is undefined.

Fixes db-migrate#343

* Fix promise issue for down migrations.

* refactor(migration): Make check for promise more reliable

* fix(test): Stub MySQL connect method instead of calling the original

The MySQL driver now connects directly to the driver, instead on the first query. This
caused some trouble with the ssh tunnel test, this functionality was stubbed.

Fixes db-migrate#348

* chore(security): Bump dependency because of security vulnerability

* pull down package.json

* chore(dependencies): update and remove unneeded dependencies

* Update data_type.js

For consistency :-)

* chore(travis): change travis config to use modern compiler

* chore(travis): add node 5 to ci builds

* chore(travis): remove obsolete node 4.1

Keep 4.2 lts and node 4 in the build which is usually enough.

* Avoid warning in promise/callback bridge code

When Bluebird detects when a promise is created within a promise
handler, but is not returned, it [emits a warning][warn] 'a promise was
created in a handler but was not returned from it'.

This happens if the `callback()` function is implemented using Promises,
but uses `nodeify()` to make it callback compatible. By using nodeify
here, it handles the returned Promise (if any) and avoids the warning.

 [warn]: https://github.com/petkaantonov/bluebird/blob/master/docs/docs/warning-explanations.md

* Updated documentation link in README

Current documentation link points to a 404 page, updated it with a working version.

* chore(travis): add node 6

* fix(api): fix race condition on create migration

A callback was placed not inside but after the callback which it belongs to. This
resulted in a very rarely occuring race condition when creating migrations without
an existing migration directory.

Fixes db-migrate#376

* 0.10.0-beta.12

* chore(compatibility): update dependencies

* chore(dev): add .tern file to project

* refactor(log): move log into new extern lib

Refers to db-migrate#382

* refactor(datatype): move dataType into new extern lib

Refers to db-migrate#382

* refactor(remove): remove log and dataType artifacts

Refers to db-migrate#382

* refactor(util): remove util artifact

Resolves db-migrate#382

* detect real callback for several api functions

* feat(api): promisify all current api methods

* refactor(ssh): delay loading of tunnel-ssh and improve load time

This improves the loadtime of db-migrate by 47%. To be exact from ~22ms to ~15ms.

Resolves db-migrate#387

* refactor(modularize): require inflection from npm instead

* refactor(tests): added shadow test and rewrite api test

* chore(comments): add some notes to the api tests

* refactor(globals): remove several globals, this might break things

There are several things that are exposed as global. For example Migrator, Seeder, Class, or the async and dbm globals.

Most probably finally removing async and dbm which have been marked deprecated, will end up for some people in a breaking change. But we need to remove all those
globals, to not interfere with projects using db-migrate. DB-Migrate is not just a cli module anymore though. In this step we now also finally removed internals completely
from the API, and needed to adjust the onComplete callback to actually do this. This change could also lead to a breaking change and should thus be communicated

All in all this is a big clean up and also two not necessary functions were removed.

* chore(parallelize): parallelize non interferring api tests

* refactor(tests): add index tests and some configs

* refactor(tests): refactored util_tests

* refactor(tests): refactored migration tests

* refactor(tests): refactored config tests

* refactor(tests): refactored base tests

* refactor(tests): add create tests and remove sample shadows

* chore(ci,dep): update ci and dependencies

* chore(test): create Makefile for tests and edit ci config

Removing 0.10 and 0.12 from tests

* chore(ci): clean up ci config

* chore(dependencies): upgrade dotenv and pkginfo

* chore(devdep): update and remove some devDependencies

* use path.join (db-migrate#353)

refactor(template): use path.join as it is intended to be used

* fix(template): fix unnoticed error introduced in the last merge request

Wrong migrations have been generated

* feat(plugins): add basic support for plugins and improve performance

Some libraries have been changed to be delay loaded. DB-Migrate is back to the minimal load time possible again, if no command at all is entered.

Basic plugin support and the first hook, in this case of the type overwrite has been added. An functional example of a yaml config plugin
has been published.
Also some old functions have been cleaned up which are not necessary any more.

refers to db-migrate#397

* chore(leftover): remove example plugin leftover from package.json

* fix(api): fix introduced undefined behavior of specified configs

internal.cwd added again, which is needed.

* fix(api): fix scoping

The api was missing the matching internal, which resulted in a missing prefix
when executing scope migrations.

fixes db-migrate#409

* most of the first protocol transition and the transition helper
is implemented already. Just the logic to actually call the helper is currently missing.

* feat(transitioner): add transitioner to easen the process of protocol changes

Resolves db-migrate#403

* feat(hook): parser hook and transitioner api

Added a hook for parsers and added the API endpoints for the transitioner.

Refers to db-migrate#403
Refers to db-migrate#397

* fix(config): Don't throw if environment variable is empty

Fixes db-migrate#411

* chore(hook): allow also to hook without adding any extension

* fix(transitioner): add new parser internal to transitioner

* fix(transitioner): catch whitespaces properly

* chore(templates): add meta protocol v1 to already aligned migration templates

* feat(plugin): add basic plugin support

Added basic plugin support, enabling to inject at multiple targets of the API, config and register
pre compiler.

Resolves db-migrate#397
Refers db-migrate#396

* fix(plugin): use correct path to include plugins

* fix(errorhandling): Add missing error assertion in executeDB

fixes db-migrate#381

* feat(sync): add sync mode

Refers to db-migrate#383
Resolves db-migrate#313
Refers to db-migrate#222

* refactor(tests): remove tests from main repo

Tests have been moved to their driver repo.

Resolves db-migrate#399

* refactor(cleanup): cleanup package.json and add db.config.ci back

* chore(ci): exclude interfaces

* chore(ci): Readd missing dependencies

* chore(test): Add Test for privateKey param on shh tunnel

* fix(resolve): Check if resolved version has plugin support

fix db-migrate#425

* log error on undefined stack

* refactor(api): cleanup information and added commentary

* feat(config): add rc style configs

fixes db-migrate#308
fixes db-migrate#406

* refactor(api): refactor tests and make api.js more modular

* fix(api): add missing reference to sync

* refactor(api): remove last output of postponed seeders

* add test dummies for api

* add first programable api tests

* directly use promises in tests

* Double quoting interpolated file name for coffee

* fix(create): use same timestamp in every created file

* fix(args): dont parse when called as module

fixes db-migrate#449

* fix deep config replacements

fixes db-migrate#473

* feat(config): helper to overwrite and extend configuration

This allows to parse a url from an url property and as well to overwrite and extend
variables as needed.
To pass in url as normal value an object is needed like the following: { url: { value: "http://example.com } }.

Fixes db-migrate#349
Fixes db-migrate/pg#8
Fixes db-migrate#488
Fixes db-migrate#463

* fix(tests): fix breaking tests

* refactor(config): do not just interpret database.json

also check for either a passed config object OR a config file exists

* fix(create): Fix create when using db-migrate as module

Bug introduced on db-migrate#485

Fixes: db-migrate#493

* test(create): Fix testing as module when no database.json on root

* fix small typo in cli help menu

* allow rc file to contain location of config file

* print the reason in unhandledRejection evnet if reason.stack does not exist

* complete refactor of api js

* add eslint to dependencies

* fix a few bugs and update tests

* fix last tests

* adjust to cs

* adjust manual changes for cs

* remove process.exit when no callback passed and remove optimist help when in module mode

Fixes db-migrate#516

* add changelog and release 0.10.0

* 0.10.0

* adjusted tests and updated devDependencies

Refers to db-migrate#518

* readd pkg-lock

* change tested versions

* rewrite latest to node

* add linting and fix cs on config test

* add commitlint

* remove parallel: true as it was deprecated

* add stale config

* use more appropiate label

* Create CODE_OF_CONDUCT.md

* fix(db): wrong reference to connect causes db:create to fail

Fixes db-migrate#520

* 0.10.1

* add changelog

* fix(log): error ended up in unreadable errors

Fixes db-migrate#524
Fixes db-migrate#521

* add changelog

* chore: Remove `moment`.

Signed-off-by: wtgtybhertgeghgtwtg <[email protected]>

* feat(issuetemplate): added a github issue template

Signed-off-by: BorntraegerMarc <[email protected]>

* fix(exitCode): wrong check for existence fixed

A wrong check for existence resulted in events not
being loaded on version sized like 4.0.0. This resulted
in non zero error codes when actually running into errors.

Signed-off-by: Tobias Gurtzick <[email protected]>

* refactor(deprecationNotice): remove insert deprecation

This temporarily removes the note being displayed to the user
when an insert call is being made. This will be removed until
seeders really going to be introduced.

Refers to db-migrate#215

Signed-off-by: Tobias Gurtzick <[email protected]>

* fix(exitCode): wrong exit code on db methods

DB Calls always returned an exit code of 0, which leads
to an unexpected behavior on the user side.

Fixes db-migrate#534

Signed-off-by: Tobias Gurtzick <[email protected]>

* fix(switchDatabase): no error was thrown on scope switch

switchDatabase error was unhandled, which resulted in an unhandled
scope switch error.

Fixes db-migrate#470

Signed-off-by: Tobias Gurtzick <[email protected]>

* 0.10.3

* add changelog

* fix(insert): add missing insert entry to interface

Fixes db-migrate#542

Signed-off-by: Tobias Gurtzick <[email protected]>

* 0.10.4

* changelog

Signed-off-by: Tobias Gurtzick <[email protected]>

* 0.10.5

* update to use real checkboxes

* Update ISSUE_TEMPLATE.md

* feat(contribution): enrich contribution instructions

Refers to db-migrate#549

Signed-off-by: Tobias Gurtzick <[email protected]>

* feat(contribution): enrich contribution instructions, issues

Signed-off-by: Tobias Gurtzick <[email protected]>

* feat(progamableApi): CMD options can be passed programatically now

Signed-off-by: Marc Bornträger <[email protected]>

* fix(ci): add ignores for backported features

Signed-off-by: Tobias Gurtzick <[email protected]>

* chore: update dependencies

Signed-off-by: Tobias Gurtzick <[email protected]>

* feat(progamableApi): using const now

Signed-off-by: BorntraegerMarc <[email protected]>

* add changelog

Signed-off-by: Tobias Gurtzick <[email protected]>

* 0.10.6

* chore: add test to detect cmdOptions functionality

Refers to db-migrate#560
Refers to db-migrate#557

Signed-off-by: Tobias Gurtzick <[email protected]>

* fix(progamableApi): cmdOptions get passed into setDefaultArgv now

Signed-off-by: Marc Bornträger <[email protected]>

* 0.10.7

* add changelog

Signed-off-by: Tobias Gurtzick <[email protected]>

* chore: update dependency

Signed-off-by: Tobias Gurtzick <[email protected]>

* chore: update dependency

Signed-off-by: Tobias Gurtzick <[email protected]>

* feat(check): add check functionality to determine migrations to run

Signed-off-by: RandomSeeded <[email protected]>

* 0.11.0

* add changelog

Signed-off-by: Tobias Gurtzick <[email protected]>

* fix(reset): regression introduced in check functionality

db-migrate#552 introduced a regression and effectively disfunctioned the reset function, since it
did append just to the actionables within the run context.

It was moved into its own context.

Signed-off-by: Tobias Gurtzick <[email protected]>

* add changelog

Signed-off-by: Tobias Gurtzick <[email protected]>

* 0.11.1

* fix(check): fix check via API not passing results to the callback

Signed-off-by: RandomSeeded <[email protected]>

* save

* save

* updates

* cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants