47 Commits

Author SHA1 Message Date
André Cruz
c2dff7f843 Implemented extra boolean param for rollback() (#2968)
* Implemented extra boolean param for rollback()
Extra parameter allows all migrations to be rolled back.

* Removed spurious log

* Removed stray debugger instruction

* Moved to arrow functions
2018-12-20 17:05:28 -06:00
Randy Garces
ab35e97614 GH-2915 Oracledb tests are failing (#2924)
* GH-2915 Oracledb tests are failing

- fixes oracledb failing tests

* Fixes oracledb increment() and decrement() empty query

- Error: The query is empty

* Add ToDo for fixing Oracle bug
2018-11-23 12:58:23 +01:00
Neil Gentleman
833829aff1 Fix failed migration filename (#2910)
* Fix migration test assertions

* Report failing migration instead of latest migration

Migrator._activeMigration needs to be set twice: once when loading the
migration, and again when running it.
2018-11-16 01:23:13 +01:00
Henry Williams
2611e5a300 Fix linter errors in tests (#2859)
* fix lint errors for tests
2018-10-15 22:29:53 -04:00
Igor Savin
d4a3387c56 Pass migration config object as an argument to the migrations (V 2.0) (#2802)
* Pass migration config object as an argument to the migrations themselves, to allow custom parameters to be set for migrations. (#2014)

* Run prettier

* Remove unneeded change

* Remove more unneeded changes

* Fix Node 10 support

* Update documentation based on a new design

* Restore test execution (oops)

* Fix withUserParams method

* Fix knex instance cloning

* Remove unused import

* Fix reference to knex from migrator

* Do not lose user params on transactions

* Remove unneeded require

* Address review comments

* Fix setting event emitter and listeners on Knex copies. Use knex copies to run tests in CI

* Remove knex cloning

* Fix event listener leak
2018-09-26 23:27:59 +03:00
Jake Ginnivan
bf1e384ed6 Introduced abstraction for getting migrations (#2775)
* Introduced abstraction for getting migrations

This would allow a webpack migration source which is compatible with bundling.

* Fixed migration validation with custom migration source

* Fixed issues after rebasing on muti directory PR

* Renamed parameter and fixed error message

* Addressed some PR comments

* Finished comment

* Moved filename extension filtering into fs-migrator

* Added test showing in memory custom migration source

* Cleaned up how to get config

* Fixed failing test

* Hopefully fix tests

* Fix Node.js 10 support in tests
2018-09-12 14:58:37 +03:00
Igor Savin
91f23bc02f Feature/2690: Multiple migration directories (#2735)
* Implement support for multiple migration directories

* Add tests for new functionality

* Fix tape tests

* Pass migration directory upwards

* Fix multiple directory support

* Fix bugs

* Rollback correctly

* Fix remaining tests

* Address comments
2018-08-24 12:39:20 +03:00
Tim Griesser
232fe9f151
Add Prettier (#2697)
* Add prettier
* Run files through prettier
2018-07-09 08:10:34 -04:00
Mikael Lepistö
cb3a85e738
Normalized and validated driverNames of test db clients and fixed oracle test setup (#2692)
* Normalized and validated driverNames of test db clients and fixed oracle test setup

* Fixed failed queries from old query building tests which hadn't been ran in ages

* Allow selecting node version which is used to run oracledb docker tests

* Improved sql tester error messages

* Fixed rest of the oracledb tests

* Removed invalid flag from docker-compose

* Print mssql logs if initialization fails

* Fixed syntax error + final tests

* Added restart of failure for mssql DB initialization to try again if server was not ready

* Printout always mssql logs after container is started

* Fixed wait time printing after trying to connect

* Use npm run oracledb:test for testing oracle in travis
2018-07-08 14:10:51 +03:00
Mikael Lepistö
e2f617b968
Drop mariadb support (#2681)
* Dropped support for mariasql

* ESLint
2018-07-01 23:06:26 +03:00
Mikael Lepistö
b349ac4a8c
Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float

* Many tests where postgres test was not actually ran at all

* Migrations to be mssql compatible

Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.

* Prevented mssql failing when invalid schema builder was executed by accident

Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started

* Fixed mssql trx rollback to always throw an error

Also modified some connection test query to be mssql compatible

* Fixed various bugs from MSSQL driver to make tests run

* Fixed mssql unique index to be compatible with other dialect implementations

* Enable running mssql tests on CI

* Test for #2588

* Updated tests to not be dependend on tables left from previous test rans

* Trying to make mssql server work on travis
2018-06-29 10:47:06 +03:00
Igor Savin
843a16799d Support DB schema for migrations - fixes #2499 (#2559)
* WIP

* implement schema support for migrations

* Refactor

* Cleanup

* Restore unneeded changes

* Restore more removed code

* Restore newline

* Execute all tests

* Fix linting error

* Add schema creation

* Drop tables before dropping schema

* Cascade drop for schema
2018-04-05 01:19:08 +03:00
Adam Cofer
5f81e8aeb9 Add redshift support without changing cli or package.json (#2233)
* Add a Redshift dialect that inherits from Postgres.

* Turn .index() and .dropIndex() into no-ops with warnings in the Redshift dialect.

* Update the Redshift dialect to be compatible with master.

* Update package.json

* Disable liftoff cli

* Remove the CLI

* Add lib to the repo

* Allow the escaping of named bindings.

* Update dist

* Update the Redshift dialect’s instantiation of the query and column compilers.

* Update the distribution

* Fix a merge conflict

* Take lib back out

* Trying to bring back in line with tgreisser/knex

* Add npm 5 package-lock

* Bring cli.js back in line

* Bring cli.js back in line

* Progress commit on redshift integration tests

* Revert "Progress commit on redshift integration tests"

This reverts commit 207e31635c638853dec54ce0580d34559ba5a54c.

* Progress commit

* Working not null on primary columns in createTable

* Working redshift unit tests

* Working unit and integration tests, still need to fix migration tests

* Brought datatypes more in line with what redshift actually supports

* Added query compiler unit tests

* Add a hacky returning clause for redshift ugh

* Working migration integration tests

* Working insert integration tests

* Allow multiple insert returning values

* Working select integration tests

* Working join integration tests

* Working aggregate integration tests

* All integration suite tests working

* Put docker index for reconnect tests back

* Redshift does not support insert...returning, there does not seem to be a way around that, therefore accept it and test accordingly

* Leave redshift integration tests in place, but do not run them by default

* Fix mysql order by test

* Fix more tests

* Change test db name to knex_test for consistency

* Address PR comments
2018-02-03 15:33:02 +02:00
itaysabato
a5f4c39529 Migration transaction (#1962)
* Use transaction for entire migration batch + locking if all migrations are transactional.

* Fix tests.
Use knex instead of query builder.
Do no use single transaction if `disableTransactions` is true.

* Added tests for parallel migrations.
Subtract already done migrations after getting the lock, when there is a wrapping transaction.

* Fix indentation.

* Fix linting errors (which are locally warnings, for some reason).

* Remove `const` keyword.
Remove obsolete `it` clauses.

* No maria. PG first.

* Test only pg and oracle.

* Remove error swallowing.

* Test parallel migration only in postgres (select for update works differently in other databases).

* Add transaction to missed places.

* Remove ignored table name argument.

* Enabled parallel migrations test for `mssql` dialect (still not part of CI test).
Fixed indentation.
2017-03-27 17:39:08 +03:00
Tim Griesser
6fa485302b Bluebird cleanup (#1618)
* Reference Bluebird directly, Remove deprecated .exec method
* Remove outdated bench scripts
* Remove old .jshintrc file
2016-08-09 17:23:07 -04:00
Rhys van der Waerden
2e7650a8e4 Remove JSHint comments 2016-05-18 20:07:33 +10:00
wubzz
1d27fb8550 Update lodash from 3.7.0 -> 4.6.0 2016-03-15 18:11:13 +01:00
Mikael Lepistö
bccf1280d9 Smoke test to verify _runBatch return value 2016-02-13 14:49:25 +02:00
Mikael Lepistö
9236ca95e3 Fixed typo and moved LockError emitting to inside _getLock function 2015-12-15 21:47:59 +02:00
Mikael Lepistö
d510b2377f Made tests compatible with node 0.10 and 0.12 2015-12-15 21:37:01 +02:00
Mikael Lepistö
4ae8974a95 Command to migration client to allow freeing migration lock manually 2015-12-15 21:37:01 +02:00
Mikael Lepistö
8f8fe5979e Fixed error messages to be more descriptive and minor refactoring 2015-12-15 21:37:01 +02:00
Dustin Martin
b323013b20 Add migration locking so multiple services cannot try to run migrations
at same time
2015-12-15 21:37:01 +02:00
Dustin Martin
d9ac2c1f8f Add status method
Returns 0 if all migrations are run and DB is up to date. Return negative number if DB is missing migrations. Return positive number if DB is ahead (rare case, e.g. if migrations were run then code is reverted)
2015-11-23 10:50:19 -06:00
harriha
3d85822a28 Add integration tests for per-migration transactions
Since per-migration config is defined in the migration files
themselves, new test migration files are needed.
2015-09-08 13:59:27 +10:00
harriha
a095feee21 Add a test for checking migrations with all transactions disabled 2015-09-08 13:59:27 +10:00
harriha
e614e89d22 Add missing return 2015-09-08 13:59:26 +10:00
Tim Griesser
01bae6a598 Add disableTransactions option, #834 2015-05-20 11:08:27 -04:00
Tim Griesser
ff76297506 Normalize connection config, fix #789 2015-04-29 15:14:41 -04:00
Tim Griesser
f735dcb9c8 Raw identifiers and named parameters
Adds ?? for interpolating identifiers in raw
statements. Also adds raw(sql, obj) for
named :key syntax. Alternatively, 🔑
(trailing colon) may be used to specify an
identifier as a parameter.
2015-04-27 15:58:48 -04:00
Stephan Schneider
06d3383c11 Uses knex.client.dialect instead of hacky knex.toString() 2015-01-23 15:43:14 +01:00
Stephan Schneider
9159a4a5dc Makes transaction test MySQL comliant 2015-01-09 14:57:37 +01:00
Stephan Schneider
fa7ff8cd23 Adds tests for transaction-based migrations 2015-01-09 11:00:55 +01:00
Vincent Schoettke
98f4f9a1dd Removed jshint expr and fixed warnings 2014-09-02 22:03:14 +02:00
Vincent Schoettke
f3874ac651 Fixed several jshint warnings. Added strict mode 2014-09-01 17:19:34 +02:00
Vincent Schoettke
9ef99b5f92 Added oracle support 2014-08-13 21:53:42 +02:00
Noah Santorello
97c8c820e6 Made migration CLI tasks output absolute paths 2014-07-21 19:48:31 -04:00
Noah Santorello
26e4135f7f Fixing path issues in migration and seed functionality 2014-07-21 19:27:26 -04:00
Tim Griesser
f7ad182e68 working on a lot of tooling, migration pieces 2014-05-28 22:29:34 -04:00
Johannes Lumpe
838b53a2d8 Made migration tests pass 2014-04-27 12:00:51 +03:00
Tim Griesser
4c589cc960 working on refactoring the internals 2014-02-14 12:46:13 -05:00
Tim Griesser
f06ee1acd2 ensure ordering on migration test 2013-11-29 12:48:25 -05:00
Ben Drucker
a9df0a11c7 Additional integration testing to confirm that migrations actually alter schemas as expected 2013-11-29 10:00:42 -05:00
Tim Griesser
20c7b20f73 removing listAll test and other unused tests 2013-11-25 01:45:15 -05:00
Tim Griesser
f78fc3e199 continuing work on migrations cli 2013-11-25 00:55:26 -05:00
Tim Griesser
7a6937fdb3 cleanup for readability of migrations, mostly done 2013-11-02 17:39:52 -04:00
Tim Griesser
86a1a24a1a some work on the migration code & api 2013-10-24 21:54:35 -04:00