Skip to content

Commit

Permalink
Merge 47ebd6b into e143fb1
Browse files Browse the repository at this point in the history
  • Loading branch information
snyk-bot authored Apr 29, 2021
2 parents e143fb1 + 47ebd6b commit 2a6b92d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"mustache": "4.2.0",
"parse": "3.1.0",
"pg-monitor": "1.4.1",
"pg-promise": "10.9.2",
"pg-promise": "10.10.1",
"pluralize": "8.0.0",
"redis": "3.1.1",
"semver": "7.3.4",
Expand Down
11 changes: 4 additions & 7 deletions src/Adapters/Storage/Postgres/PostgresStorageAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1056,28 +1056,25 @@ export class PostgresStorageAdapter implements StorageAdapter {
conn = conn || this._client;
const self = this;

await conn.tx('schema-upgrade', async t => {
await conn.task('schema-upgrade', async t => {
const columns = await t.map(
'SELECT column_name FROM information_schema.columns WHERE table_name = $<className>',
{ className },
a => a.column_name
);
const newColumns = Object.keys(schema.fields)
.filter(item => columns.indexOf(item) === -1)
.map(fieldName =>
self.addFieldIfNotExists(className, fieldName, schema.fields[fieldName], t)
);
.map(fieldName => self.addFieldIfNotExists(className, fieldName, schema.fields[fieldName]));

await t.batch(newColumns);
});
}

async addFieldIfNotExists(className: string, fieldName: string, type: any, conn: any) {
async addFieldIfNotExists(className: string, fieldName: string, type: any) {
// TODO: Must be revised for invalid logic...
debug('addFieldIfNotExists');
conn = conn || this._client;
const self = this;
await conn.tx('add-field-if-not-exists', async t => {
await this._client.tx('add-field-if-not-exists', async t => {
if (type.type !== 'Relation') {
try {
await t.none(
Expand Down

0 comments on commit 2a6b92d

Please sign in to comment.