-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Add redshift support without changing cli or package.json #2233
Merged
Merged
Changes from 21 commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
aa02e58
Add a Redshift dialect that inherits from Postgres.
trevorsmith 8335adb
Turn .index() and .dropIndex() into no-ops with warnings in the Redsh…
trevorsmith e470351
Update the Redshift dialect to be compatible with master.
trevorsmith 75dc23a
Update package.json
trevorsmith dd7820c
Disable liftoff cli
trevorsmith 2dc1b2b
Remove the CLI
trevorsmith 5fe08ef
Add lib to the repo
trevorsmith c932345
Allow the escaping of named bindings.
trevorsmith 7e89c1b
Update dist
trevorsmith 2f2626c
Update the Redshift dialect’s instantiation of the query and column c…
trevorsmith f6e3bb5
Update the distribution
trevorsmith 7f294a1
Fix a merge conflict
trevorsmith fad6417
Take lib back out
acofer 5dafccd
Trying to bring back in line with tgreisser/knex
acofer aea2cc4
Merge branch 'master' into master
acofer 847cf11
Merge pull request #1 from acofer/master
acofer b807272
Add npm 5 package-lock
acofer 3667d2a
Bring cli.js back in line
acofer 4f542b5
Bring cli.js back in line
acofer cb5ca92
Merge branch 'master' of github.com:skuid/knex
acofer 207e316
Progress commit on redshift integration tests
acofer e811206
Revert "Progress commit on redshift integration tests"
acofer 68b9740
Progress commit
acofer 1046848
Working not null on primary columns in createTable
acofer 73db01e
Working redshift unit tests
acofer 9633eb1
Working unit and integration tests, still need to fix migration tests
acofer 001c270
Brought datatypes more in line with what redshift actually supports
acofer 8a480fd
Added query compiler unit tests
acofer 841d670
Add a hacky returning clause for redshift ugh
acofer 5cdb44d
Working migration integration tests
acofer c4d2bc6
Working insert integration tests
acofer f0de2a2
Allow multiple insert returning values
acofer add23b6
Working select integration tests
acofer 4a5cc77
Working join integration tests
acofer ec66caf
Working aggregate integration tests
acofer fcf71e5
All integration suite tests working
acofer d6971b2
Put docker index for reconnect tests back
acofer 918e252
Merge remote-tracking branch 'upstream/master'
acofer c1b16c0
Redshift does not support insert...returning, there does not seem to …
acofer a12d757
Merge branch 'master' into master
acofer b41c5d4
Leave redshift integration tests in place, but do not run them by def…
acofer ca3c54a
Fix mysql order by test
acofer eac973d
Fix more tests
acofer ae21482
Merge branch 'master' into master
acofer 5200d03
Merge remote-tracking branch 'upstream/master'
acofer 095c403
Change test db name to knex_test for consistency
acofer 78a48af
Merge branch 'master' of github.com:skuid/knex
acofer 3887f3f
Merge branch 'master' into master
elhigu 007180a
Address PR comments
acofer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ raw | |
.DS_Store | ||
.vagrant | ||
node_modules | ||
package-lock.json | ||
test.sqlite3 | ||
npm-debug.log | ||
tmp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ -n "$(which docker)" ]; then | ||
DOCKER_IMAGES=("mysql:5.7" "postgres:9.6") | ||
DOCKER_IMAGES=("mysql:5.7" "postgres:9.6" "quay.io/skuid/docker-aws-redshift") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these docker images are for connection breaking etc tests, not used for general travis CI integration tests. |
||
for image in ${DOCKER_IMAGES[@]}; do | ||
if [ -z "$(docker images -q ${image})" ]; then | ||
echo "Installing Docker image ${image}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
// Redshift | ||
// ------- | ||
import inherits from 'inherits'; | ||
import Client_PG from '../postgres'; | ||
import { assign } from 'lodash' | ||
|
||
import Transaction from './transaction'; | ||
import QueryCompiler from './query/compiler'; | ||
import ColumnCompiler from './schema/columncompiler'; | ||
import TableCompiler from './schema/tablecompiler'; | ||
import SchemaCompiler from './schema/compiler'; | ||
|
||
function Client_Redshift(config) { | ||
Client_PG.apply(this, arguments) | ||
} | ||
inherits(Client_Redshift, Client_PG) | ||
|
||
assign(Client_Redshift.prototype, { | ||
transaction() { | ||
return new Transaction(this, ...arguments) | ||
}, | ||
|
||
queryCompiler() { | ||
return new QueryCompiler(this, ...arguments) | ||
}, | ||
|
||
columnCompiler() { | ||
return new ColumnCompiler(this, ...arguments) | ||
}, | ||
|
||
tableCompiler() { | ||
return new TableCompiler(this, ...arguments) | ||
}, | ||
|
||
schemaCompiler() { | ||
return new SchemaCompiler(this, ...arguments) | ||
}, | ||
|
||
dialect: 'redshift', | ||
|
||
driverName: 'pg', | ||
|
||
_driver() { | ||
return require('pg') | ||
}, | ||
}) | ||
|
||
export default Client_Redshift; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
// Redshift Query Builder & Compiler | ||
// ------ | ||
import inherits from 'inherits'; | ||
|
||
import QueryCompiler_PG from '../../postgres/query/compiler'; | ||
|
||
import { assign } from 'lodash' | ||
|
||
function QueryCompiler_Redshift(client, builder) { | ||
QueryCompiler_PG.call(this, client, builder); | ||
} | ||
inherits(QueryCompiler_Redshift, QueryCompiler_PG); | ||
|
||
assign(QueryCompiler_Redshift.prototype, { | ||
truncate() { | ||
return `truncate ${this.tableName}`; | ||
}, | ||
|
||
_returning(value) { | ||
return ''; | ||
} | ||
}) | ||
|
||
export default QueryCompiler_Redshift; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
// Redshift Column Compiler | ||
// ------- | ||
|
||
import inherits from 'inherits'; | ||
import ColumnCompiler_PG from '../../postgres/schema/columncompiler'; | ||
|
||
import { assign } from 'lodash' | ||
|
||
function ColumnCompiler_Redshift() { | ||
ColumnCompiler_PG.apply(this, arguments); | ||
} | ||
inherits(ColumnCompiler_Redshift, ColumnCompiler_PG); | ||
|
||
assign(ColumnCompiler_Redshift.prototype, { | ||
bigincrements: 'bigint identity(1,1) primary key not null', | ||
binary: 'varchar(max)', | ||
bit(column) { | ||
return column.length !== false ? `char(${column.length})` : 'char(1)'; | ||
}, | ||
blob: 'varchar(max)', | ||
datetime: 'timestamp', | ||
enu: 'text', | ||
enum: 'text', | ||
increments: 'integer identity(1,1) primary key not null', | ||
json: 'varchar(max)', | ||
jsonb: 'varchar(max)', | ||
longblob: 'varchar(max)', | ||
mediumblob: 'varchar(max)', | ||
set: 'text', | ||
text: 'varchar(max)', | ||
timestamp: 'timestamp', | ||
tinyblob: 'text', | ||
uuid: 'char(32)', | ||
varbinary: 'varchar(max)' | ||
}) | ||
|
||
export default ColumnCompiler_Redshift; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* eslint max-len: 0 */ | ||
|
||
// Redshift Table Builder & Compiler | ||
// ------- | ||
|
||
import inherits from 'inherits'; | ||
import SchemaCompiler_PG from '../../postgres/schema/compiler'; | ||
|
||
import { assign } from 'lodash'; | ||
|
||
function SchemaCompiler_Redshift() { | ||
SchemaCompiler_PG.apply(this, arguments); | ||
} | ||
inherits(SchemaCompiler_Redshift, SchemaCompiler_PG); | ||
|
||
assign(SchemaCompiler_Redshift.prototype, { | ||
|
||
// dropTableIfExists(tableName) { | ||
// // Nota bene: Redshift actually supports 'IF EXISTS', but the | ||
// // docker container used for integrations tests does not. | ||
// let sql = 'case when (select 1 from information_schema.tables where table_name = ?'; | ||
// const bindings = [tableName]; | ||
// if (this.schema) { | ||
// sql += ' and table_schema = ?'; | ||
// bindings.push(this.schema); | ||
// } else { | ||
// sql += ' and table_schema = current_schema()'; | ||
// } | ||
// sql += ') then drop table ?;'; | ||
// bindings.push(tableName); | ||
// this.pushQuery({ | ||
// sql, | ||
// bindings, | ||
// output(resp) { | ||
// return resp.rows.length > 0; | ||
// } | ||
// }); | ||
// }, | ||
|
||
// Check whether the current table | ||
hasTable(tableName) { | ||
let sql = 'select * from information_schema.tables where table_name = ?'; | ||
const bindings = [tableName]; | ||
if (this.schema) { | ||
sql += ' and table_schema = ?'; | ||
bindings.push(this.schema); | ||
} else { | ||
sql += ' and table_schema = current_schema()'; | ||
} | ||
this.pushQuery({ | ||
sql, | ||
bindings, | ||
output(resp) { | ||
return resp.rows.length > 0; | ||
} | ||
}); | ||
}, | ||
}); | ||
|
||
export default SchemaCompiler_Redshift; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* eslint max-len: 0 */ | ||
|
||
// Redshift Table Builder & Compiler | ||
// ------- | ||
|
||
import { warn } from '../../../helpers'; | ||
import inherits from 'inherits'; | ||
import TableCompiler_PG from '../../postgres/schema/tablecompiler'; | ||
|
||
function TableCompiler_Redshift() { | ||
TableCompiler_PG.apply(this, arguments); | ||
} | ||
inherits(TableCompiler_Redshift, TableCompiler_PG); | ||
|
||
TableCompiler_Redshift.prototype.index = function(columns, indexName, indexType) { | ||
warn('Redshift does not support the creation of indexes.'); | ||
}; | ||
TableCompiler_Redshift.prototype.dropIndex = function(columns, indexName) { | ||
warn('Redshift does not support the deletion of indexes.'); | ||
}; | ||
|
||
export default TableCompiler_Redshift; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
import Promise from 'bluebird'; | ||
import { warn } from '../../helpers'; | ||
import Transaction from '../../transaction'; | ||
|
||
export default class Redshift_Transaction extends Transaction { | ||
savepoint(conn) { | ||
warn('Redshift does not support savepoints.'); | ||
return Promise.resolve() | ||
} | ||
|
||
release(conn, value) { | ||
warn('Redshift does not support savepoints.'); | ||
return Promise.resolve() | ||
} | ||
|
||
rollbackTo(conn, error) { | ||
warn('Redshift does not support savepoints.'); | ||
return Promise.resolve() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,9 +97,15 @@ export default class Migrator { | |
|
||
forceFreeMigrationsLock(config) { | ||
this.config = this.setConfig(config); | ||
console.log("LOOKING FOR LOCKTABLENAME"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. leftover debug prints should be removed |
||
const lockTable = this._getLockTableName(); | ||
console.log(`LOOKING FOR HASTABLE(${lockTable}) with ${typeof this.knex.schema.hasTable}`); | ||
debugger; | ||
return this.knex.schema.hasTable(lockTable) | ||
.then(exist => exist && this._freeLock()); | ||
.then(exist => { | ||
console.log("LOOKING FOR EXIST"); | ||
return exist && this._freeLock(); | ||
}); | ||
} | ||
|
||
// Creates a new migration, with a given name. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have you removed coverage and tape tests and pre_test script call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a progress commit. I should have cut a feature branch. I'll ping you when it's ready.