79 Commits

Author SHA1 Message Date
Igor Savin
e6d5873cec
Fix migration locking for cockroachdb (#4717) 2021-10-10 02:07:56 +03:00
michaelbrewerdavis
b5225179ce
fix migrate:up for migrations disabling transactions (#4550) 2021-08-31 23:05:35 +03:00
Matt Machuga
0ab482bcfb
Unify db test helpers (#4356) 2021-03-08 14:16:07 +02:00
Igor Savin
511ea2be0f
Querybuilder cleanup (#4282) 2021-02-08 16:54:00 +02:00
Igor Savin
2aec21ed5e
Try to introduce some organization into how files are grouped (#4178) 2020-12-28 16:55:08 +02:00
Rijk van Zanten
b7e1ffd7d5
Add support for dropForeign in SQLite (#4092)
Co-authored-by: Igor Savin <iselwin@gmail.com>
2020-12-08 14:49:41 +02:00
Igor Savin
4a1638bfbe
Fix double merging of config for migrator (#4040) 2020-09-25 08:03:17 +02:00
Keno Medenbach
2bd2ecd91c
MSSQL: Added the removal of a columns default constraint, before dropping the column (#3855) 2020-05-15 11:28:34 +02:00
Igor Savin
c0afe14cde
Warn user if custom migration source is being reset (#3839) 2020-05-06 00:13:09 +02:00
Igor Savin
38f54ce8f0
Refactor migration logic to use async/await. Add test case for using classes with custom migration sources (#3838) 2020-05-05 19:10:50 +02:00
Igor Savin
e37aeaa31c
Prepare for 0.21.0 release (#3811) 2020-04-19 00:40:23 +02:00
Brian Lauber
9d07bc97ea
Removed some globals from tests (#3712)
* `chai` is no longer global

* sinon is no longer globally defined

* expect(..) is no longer defined globally

* Removed obsolete eslint hints about globals

* Removed unused variable ( `expect(..)` )
2020-03-08 19:48:23 -04:00
maximelkin
8159f04c12
Remove dependency on bluebird methods from tests (#3682)
* Remove dependency on bluebird methods from tests
* Introduce `"chai-as-promised"` plugin
* Minor enhancements to the testing logic
2020-02-24 19:24:30 -05:00
Jake Coffman
d50d00644c
oracledb: commit was a no-op causing race conditions (#3668)
The underlying issue was that query *always* committed, even during a transaction. The previous fix was to just disable commitAsync in a transaction but then that also disabled explicit commit calls. Instead, this fix disables query's commits during transactions so that explicit commits still work.
2020-02-16 20:26:13 +01:00
Nekrasov Ilya
6b9fb0ec01 disable_migrations_list_validation_feature (#3448) 2019-10-12 21:45:39 +02:00
EthanHur
f782348da7 replace Bluebird.map to Promise.all (#3469) 2019-10-09 14:39:45 +02:00
Roland Németh
c1d20270d6 Fix handling of multiline SQL in SQLite3 schema (#3411) 2019-10-06 18:27:52 +02:00
Ben Darnell
8f40f8d534 migrate: Refactor _lockMigrations to avoid forUpdate (#3395) 2019-08-28 13:27:18 +02:00
Igor Savin
e971c5198b
Update dependencies, fix new eslint errors (#3339) 2019-07-10 20:47:56 +02:00
Igor Savin
1e950b93e4
Name Bluebird usage explicitly. Remove spread and thenReturn (#3285) 2019-06-17 02:14:17 +02:00
Igor Savin
c431ffc35a
Drop support for Node.js 6. Remove babel. (#3227) 2019-06-04 00:37:17 +02:00
Lee Allen
1fe5ee0ea3 Add migrate:down functionality (#3228) 2019-05-30 00:37:18 +02:00
Lee Allen
08478f2db9 Feature/add up for migrations (#3205)
* Add ability to run migrate:up command to only run the next migration

* Add cli test for migrate:up

* Add test for migrator

* Add stub

* Add type

* Fix wording of test
2019-05-19 04:14:52 -07:00
Mikael Lepistö
8a9a648ae2
Docker based test dbs (#3157)
* Fixed some of the tests failing with various dialect combinations

* Setup all test databases to run in docker

* Fixed test suite and updated travis to use docker

* Fixed some tests in master and disabled oracle tests while setting everything else to work again

* Changed docker to use latest postgresql alpine image

* Re-enabled all oracledb tests

* Install oracle client libs to oracle server and copy them to travis to make node oracledb package to work

* Disabled random failing oracle tests and added test to show that oracle update in transaction does not seem to work ACID

* Update package.json

* Update package.json

* Fixed linting issues

* Fixed waiting for postgres to use the same DB image that database is using.

* Removed installing oracledb driver in travis if not needed .travis.yml

* Cleaned up package.json more

* Created static name for oracledb container to allow copying files out of it on different docker versions

* Removed webpack from deps
2019-05-13 12:21:36 +03:00
Lee Allen
a2ab754eed Bugfix/rollback all wrong order (#3172)
* Fix rollback all bug attempting to perform rollback in chronological order

* Set up second migration to depend on first migration so when rolling back order is tests

* Add test for rollback all only running completed tests in reverse chronological order
2019-05-01 00:21:49 +02:00
Igor Savin
fe6083eda4 Support nullable timestamps on MySQL (#3100)
* Add test to recreate the issue

* Improve test, add some documentation

* Improve test

* Add explicit nullable flag to column

* Set nullability explicitly on MySQL to deal with timestamp edge case

* Use same assertion for everything
2019-03-30 15:58:56 +02:00
Igor Savin
1b39d67550
Tests for drop-and-recreate with async/await (#3083)
* Add test for drop-and-recreate with async/await

* Add some tests with schema

* Use correct migrations

* Add tests with promise chains for comparison

* Fix migration

* Fix Node 6 compatibility
2019-03-05 01:03:51 +01:00
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