From 00a6e8c87697e016806547b4ad75d4a5d5e616df Mon Sep 17 00:00:00 2001 From: Finn Woelm Date: Sat, 22 Aug 2020 07:19:44 +0200 Subject: [PATCH 1/9] Install pg-hstore According to the Getting Started page of Sequelize, pg-hstore is required for Postgres: https://sequelize.org/master/manual/getting-started.html --- package-lock.json | 31 ++++++++++++++++++++++--------- package.json | 1 + 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 518ea64..7a1d961 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2470,9 +2470,9 @@ "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==" }, "caniuse-lite": { - "version": "1.0.30001116", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001116.tgz", - "integrity": "sha512-f2lcYnmAI5Mst9+g0nkMIznFGsArRmZ0qU+dnq8l91hymdc2J3SFbiPhOJEeDqC1vtE8nc1qNQyklzB8veJefQ==" + "version": "1.0.30001117", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001117.tgz", + "integrity": "sha512-4tY0Fatzdx59kYjQs+bNxUwZB03ZEBgVmJ1UkFPz/Q8OLiUUbjct2EdpnXj0fvFTPej2EkbPIG0w8BWsjAyk1Q==" }, "chalk": { "version": "2.4.2", @@ -3235,9 +3235,9 @@ } }, "electron-to-chromium": { - "version": "1.3.539", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.539.tgz", - "integrity": "sha512-rM0LWDIstdqfaRUADZetNrL6+zd/0NBmavbMEhBXgc2u/CC1d1GaDyN5hho29fFvBiOVFwrSWZkzmNcZnCEDog==" + "version": "1.3.540", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.540.tgz", + "integrity": "sha512-IoGiZb8SMqTtkDYJtP8EtCdvv3VMtd1QoTlypO2RUBxRq/Wk0rU5IzhzhMckPaC9XxDqUvWsL0XKOBhTiYVN3w==" }, "elliptic": { "version": "6.5.3", @@ -3467,9 +3467,9 @@ }, "dependencies": { "type": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/type/-/type-2.0.0.tgz", - "integrity": "sha512-KBt58xCHry4Cejnc2ISQAF7QY+ORngsWfxezO68+12hKV6lQY8P/psIkcbjeHWn7MqcgciWJyCCevFMJdIXpow==" + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/type/-/type-2.1.0.tgz", + "integrity": "sha512-G9absDWvhAWCV2gmF1zKud3OyC61nZDwWvBL2DApaVFogI07CprggiQAOOjvp2NRjYWFzPyu7vwtDrQFq8jeSA==" } } }, @@ -5350,6 +5350,14 @@ "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.3.0.tgz", "integrity": "sha512-ukMTJXLI7/hZIwTW7hGMZJ0Lj0S2XQBCJ4Shv4y1zgQ/vqVea+FLhzywvPj0ujSuofu+yA4MYHGZPTsgjBgJ+w==" }, + "pg-hstore": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/pg-hstore/-/pg-hstore-2.3.3.tgz", + "integrity": "sha512-qpeTpdkguFgfdoidtfeTho1Q1zPVPbtMHgs8eQ+Aan05iLmIs3Z3oo5DOZRclPGoQ4i68I1kCtQSJSa7i0ZVYg==", + "requires": { + "underscore": "^1.7.0" + } + }, "pg-int8": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz", @@ -6861,6 +6869,11 @@ "integrity": "sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==", "dev": true }, + "underscore": { + "version": "1.10.2", + "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.10.2.tgz", + "integrity": "sha512-N4P+Q/BuyuEKFJ43B9gYuOj4TQUHXX+j2FqguVOpjkssLUUrnJofCcBccJSCoeturDoZU6GorDTHSvUDlSQbTg==" + }, "unicode-canonical-property-names-ecmascript": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz", diff --git a/package.json b/package.json index 463ae48..75729b1 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "next": "latest", "next-on-netlify": "^2.3.2", "pg": "^8.3.2", + "pg-hstore": "^2.3.3", "react": "^16.12.0", "react-dom": "^16.12.0", "sequelize": "^6.3.4" From 8d3677f75db0a636a349c4104efe13707d57b625 Mon Sep 17 00:00:00 2001 From: Finn Woelm Date: Sat, 22 Aug 2020 07:50:17 +0200 Subject: [PATCH 2/9] Webpack: Ignore .native sequelize requires ./native file which depends on pg-native. To pack sequelize with webpack, we need to ignore this import by adding it to the list of ignored plugins in next.config.js See: https://github.com/sequelize/sequelize/issues/3781#issuecomment-537979334 --- database/index.ts | 10 +++++++--- next.config.js | 8 ++++++++ package-lock.json | 16 ++++++++++++++++ package.json | 1 + 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/database/index.ts b/database/index.ts index a039601..a72a705 100644 --- a/database/index.ts +++ b/database/index.ts @@ -1,3 +1,6 @@ +const pg = require('pg'); +delete pg.native; + import { Sequelize } from 'sequelize'; import { UserFactory } from './models/user'; @@ -10,9 +13,10 @@ const sequelize = new Sequelize({ username, password, host: process.env.HOST, + native: false, dialect: 'postgres', logging: false, - dialectModule: require('pg'), + dialectModule: pg, dialectOptions: { ssl: { rejectUnauthorized: false, @@ -39,9 +43,9 @@ const db = { (async () => { try { await sequelize.authenticate(); - console.log('Database connection has been established successfully.'); + // console.log('Database connection has been established successfully.'); } catch (error) { - console.error('Unable to connect to the database:', error); + // console.error('Unable to connect to the database:', error); } })(); diff --git a/next.config.js b/next.config.js index a9a8315..f15d403 100644 --- a/next.config.js +++ b/next.config.js @@ -1,4 +1,12 @@ module.exports = { // Target must be serverless target: 'serverless', + webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => { + // Note: we provide webpack above so you should not `require` it + // Perform customizations to webpack config + config.plugins.push(new webpack.IgnorePlugin(/.\/native/)) + + // Important: return the modified config + return config + }, }; diff --git a/package-lock.json b/package-lock.json index 7a1d961..406cfa2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1553,6 +1553,22 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.54.tgz", "integrity": "sha512-ge4xZ3vSBornVYlDnk7yZ0gK6ChHf/CHB7Gl1I0Jhah8DDnEQqBzgohYG4FX4p81TNirSETOiSyn+y1r9/IR6w==" }, + "@types/pg": { + "version": "7.14.4", + "resolved": "https://registry.npmjs.org/@types/pg/-/pg-7.14.4.tgz", + "integrity": "sha512-yCKVMCcFPZSFHGg+8qjY368uf3ruyDBPjxvOU2ZcGa/vRFo5Ti5Y6z6vl+2hxtwm9VMWUGb6TWkIk3cIV8C0Cw==", + "dev": true, + "requires": { + "@types/node": "*", + "@types/pg-types": "*" + } + }, + "@types/pg-types": { + "version": "1.11.5", + "resolved": "https://registry.npmjs.org/@types/pg-types/-/pg-types-1.11.5.tgz", + "integrity": "sha512-L8ogeT6vDzT1vxlW3KITTCt+BVXXVkLXfZ/XNm6UqbcJgxf+KPO7yjWx7dQQE8RW07KopL10x2gNMs41+IkMGQ==", + "dev": true + }, "@types/prop-types": { "version": "15.7.3", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.3.tgz", diff --git a/package.json b/package.json index 75729b1..c315679 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ }, "devDependencies": { "@types/node": "^12.12.21", + "@types/pg": "^7.14.4", "@types/react": "^16.9.16", "@types/react-dom": "^16.9.4", "typescript": "3.9.7" From 0635e07aca53d2276b82ad0a65b49d21adf31792 Mon Sep 17 00:00:00 2001 From: Finn Woelm Date: Sat, 22 Aug 2020 07:50:17 +0200 Subject: [PATCH 3/9] Set up Netlify deployment Configure netlify.toml for next-on-netlify. --- netlify.toml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/netlify.toml b/netlify.toml index f916482..fda6776 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,6 +1,7 @@ [build] - command = "npm run build && npm run export" - publish = "out" + command = "npm run build" + functions = "out_functions" + publish = "out_publish" [[plugins]] -package = "netlify-plugin-cache-nextjs" \ No newline at end of file +package = "netlify-plugin-cache-nextjs" From 336aceb76bcccc9f2464e6f0243d1dd79b81ceab Mon Sep 17 00:00:00 2001 From: Finn Woelm Date: Sat, 22 Aug 2020 07:50:17 +0200 Subject: [PATCH 4/9] Do not delete pg.native Test if we can skip this step and still succeed with build and deployment. --- database/index.ts | 5 +---- package-lock.json | 16 ---------------- package.json | 1 - 3 files changed, 1 insertion(+), 21 deletions(-) diff --git a/database/index.ts b/database/index.ts index a72a705..058df9c 100644 --- a/database/index.ts +++ b/database/index.ts @@ -1,6 +1,3 @@ -const pg = require('pg'); -delete pg.native; - import { Sequelize } from 'sequelize'; import { UserFactory } from './models/user'; @@ -16,7 +13,7 @@ const sequelize = new Sequelize({ native: false, dialect: 'postgres', logging: false, - dialectModule: pg, + dialectModule: require('pg'), dialectOptions: { ssl: { rejectUnauthorized: false, diff --git a/package-lock.json b/package-lock.json index 406cfa2..7a1d961 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1553,22 +1553,6 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.54.tgz", "integrity": "sha512-ge4xZ3vSBornVYlDnk7yZ0gK6ChHf/CHB7Gl1I0Jhah8DDnEQqBzgohYG4FX4p81TNirSETOiSyn+y1r9/IR6w==" }, - "@types/pg": { - "version": "7.14.4", - "resolved": "https://registry.npmjs.org/@types/pg/-/pg-7.14.4.tgz", - "integrity": "sha512-yCKVMCcFPZSFHGg+8qjY368uf3ruyDBPjxvOU2ZcGa/vRFo5Ti5Y6z6vl+2hxtwm9VMWUGb6TWkIk3cIV8C0Cw==", - "dev": true, - "requires": { - "@types/node": "*", - "@types/pg-types": "*" - } - }, - "@types/pg-types": { - "version": "1.11.5", - "resolved": "https://registry.npmjs.org/@types/pg-types/-/pg-types-1.11.5.tgz", - "integrity": "sha512-L8ogeT6vDzT1vxlW3KITTCt+BVXXVkLXfZ/XNm6UqbcJgxf+KPO7yjWx7dQQE8RW07KopL10x2gNMs41+IkMGQ==", - "dev": true - }, "@types/prop-types": { "version": "15.7.3", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.3.tgz", diff --git a/package.json b/package.json index c315679..75729b1 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,6 @@ }, "devDependencies": { "@types/node": "^12.12.21", - "@types/pg": "^7.14.4", "@types/react": "^16.9.16", "@types/react-dom": "^16.9.4", "typescript": "3.9.7" From b15788524b5aa801c3dfff65268460d544173e93 Mon Sep 17 00:00:00 2001 From: Finn Woelm Date: Sat, 22 Aug 2020 07:50:17 +0200 Subject: [PATCH 5/9] Install pg-native Manually install pg-native for SSL support. --- next.config.js | 8 ------ package-lock.json | 62 +++++++++++++++++++++++++++++++++++++++++++++-- package.json | 1 + 3 files changed, 61 insertions(+), 10 deletions(-) diff --git a/next.config.js b/next.config.js index f15d403..a9a8315 100644 --- a/next.config.js +++ b/next.config.js @@ -1,12 +1,4 @@ module.exports = { // Target must be serverless target: 'serverless', - webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => { - // Note: we provide webpack above so you should not `require` it - // Perform customizations to webpack config - config.plugins.push(new webpack.IgnorePlugin(/.\/native/)) - - // Important: return the modified config - return config - }, }; diff --git a/package-lock.json b/package-lock.json index 7a1d961..d717a76 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4302,6 +4302,15 @@ "leven": "^3.1.0" } }, + "libpq": { + "version": "1.8.9", + "resolved": "https://registry.npmjs.org/libpq/-/libpq-1.8.9.tgz", + "integrity": "sha512-herU0STiW3+/XBoYRycKKf49O9hBKK0JbdC2QmvdC5pyCSu8prb9idpn5bUSbxj8XwcEsWPWWWwTDZE9ZTwJ7g==", + "requires": { + "bindings": "1.5.0", + "nan": "^2.14.0" + } + }, "loader-runner": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-2.4.0.tgz", @@ -4687,8 +4696,7 @@ "nan": { "version": "2.14.1", "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz", - "integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==", - "optional": true + "integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==" }, "nanomatch": { "version": "1.2.13", @@ -5363,6 +5371,56 @@ "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz", "integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==" }, + "pg-native": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pg-native/-/pg-native-3.0.0.tgz", + "integrity": "sha512-qZZyywXJ8O4lbiIN7mn6vXIow1fd3QZFqzRe+uET/SZIXvCa3HBooXQA4ZU8EQX8Ae6SmaYtDGLp5DwU+8vrfg==", + "requires": { + "libpq": "^1.7.0", + "pg-types": "^1.12.1", + "readable-stream": "1.0.31" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" + }, + "pg-types": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-1.13.0.tgz", + "integrity": "sha512-lfKli0Gkl/+za/+b6lzENajczwZHc7D5kiUCZfgm914jipD2kIOIvEkAhZ8GrW3/TUoP9w8FHjwpPObBye5KQQ==", + "requires": { + "pg-int8": "1.0.1", + "postgres-array": "~1.0.0", + "postgres-bytea": "~1.0.0", + "postgres-date": "~1.0.0", + "postgres-interval": "^1.1.0" + } + }, + "postgres-array": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-1.0.3.tgz", + "integrity": "sha512-5wClXrAP0+78mcsNX3/ithQ5exKvCyK5lr5NEEEeGwwM6NJdQgzIJBVxLvRW+huFpX92F2QnZ5CcokH0VhK2qQ==" + }, + "readable-stream": { + "version": "1.0.31", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.31.tgz", + "integrity": "sha1-jyUC4LyeOw2huUUgqrtOJgPsr64=", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" + } + } + }, "pg-pool": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.2.1.tgz", diff --git a/package.json b/package.json index 75729b1..f0f5438 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "next-on-netlify": "^2.3.2", "pg": "^8.3.2", "pg-hstore": "^2.3.3", + "pg-native": "^3.0.0", "react": "^16.12.0", "react-dom": "^16.12.0", "sequelize": "^6.3.4" From 4df1b91b04c862381a49829555170ccf55285a7e Mon Sep 17 00:00:00 2001 From: Finn Woelm Date: Sat, 22 Aug 2020 08:05:54 +0200 Subject: [PATCH 6/9] Revert "Install pg-native" This reverts commit b15788524b5aa801c3dfff65268460d544173e93. Installing pg-native fails on netlify due to node-libpq. Seems to be a known issue: - https://community.netlify.com/t/unable-to-publish-function-using-postgres/12293/3 - https://github.com/netlify/build-image/issues/393 --- next.config.js | 8 ++++++ package-lock.json | 62 ++--------------------------------------------- package.json | 1 - 3 files changed, 10 insertions(+), 61 deletions(-) diff --git a/next.config.js b/next.config.js index a9a8315..f15d403 100644 --- a/next.config.js +++ b/next.config.js @@ -1,4 +1,12 @@ module.exports = { // Target must be serverless target: 'serverless', + webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => { + // Note: we provide webpack above so you should not `require` it + // Perform customizations to webpack config + config.plugins.push(new webpack.IgnorePlugin(/.\/native/)) + + // Important: return the modified config + return config + }, }; diff --git a/package-lock.json b/package-lock.json index d717a76..7a1d961 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4302,15 +4302,6 @@ "leven": "^3.1.0" } }, - "libpq": { - "version": "1.8.9", - "resolved": "https://registry.npmjs.org/libpq/-/libpq-1.8.9.tgz", - "integrity": "sha512-herU0STiW3+/XBoYRycKKf49O9hBKK0JbdC2QmvdC5pyCSu8prb9idpn5bUSbxj8XwcEsWPWWWwTDZE9ZTwJ7g==", - "requires": { - "bindings": "1.5.0", - "nan": "^2.14.0" - } - }, "loader-runner": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-2.4.0.tgz", @@ -4696,7 +4687,8 @@ "nan": { "version": "2.14.1", "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz", - "integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==" + "integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==", + "optional": true }, "nanomatch": { "version": "1.2.13", @@ -5371,56 +5363,6 @@ "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz", "integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==" }, - "pg-native": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pg-native/-/pg-native-3.0.0.tgz", - "integrity": "sha512-qZZyywXJ8O4lbiIN7mn6vXIow1fd3QZFqzRe+uET/SZIXvCa3HBooXQA4ZU8EQX8Ae6SmaYtDGLp5DwU+8vrfg==", - "requires": { - "libpq": "^1.7.0", - "pg-types": "^1.12.1", - "readable-stream": "1.0.31" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" - }, - "pg-types": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-1.13.0.tgz", - "integrity": "sha512-lfKli0Gkl/+za/+b6lzENajczwZHc7D5kiUCZfgm914jipD2kIOIvEkAhZ8GrW3/TUoP9w8FHjwpPObBye5KQQ==", - "requires": { - "pg-int8": "1.0.1", - "postgres-array": "~1.0.0", - "postgres-bytea": "~1.0.0", - "postgres-date": "~1.0.0", - "postgres-interval": "^1.1.0" - } - }, - "postgres-array": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-1.0.3.tgz", - "integrity": "sha512-5wClXrAP0+78mcsNX3/ithQ5exKvCyK5lr5NEEEeGwwM6NJdQgzIJBVxLvRW+huFpX92F2QnZ5CcokH0VhK2qQ==" - }, - "readable-stream": { - "version": "1.0.31", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.31.tgz", - "integrity": "sha1-jyUC4LyeOw2huUUgqrtOJgPsr64=", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" - } - } - }, "pg-pool": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.2.1.tgz", diff --git a/package.json b/package.json index f0f5438..75729b1 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,6 @@ "next-on-netlify": "^2.3.2", "pg": "^8.3.2", "pg-hstore": "^2.3.3", - "pg-native": "^3.0.0", "react": "^16.12.0", "react-dom": "^16.12.0", "sequelize": "^6.3.4" From f6cff68d5a707bebcf8d72b5cfb8ed8aff22c3b0 Mon Sep 17 00:00:00 2001 From: Finn Woelm Date: Sat, 22 Aug 2020 08:05:54 +0200 Subject: [PATCH 7/9] Remove default native option Remove native option because this is the default for sequelize according to https://sequelize.org/master/class/lib/sequelize.js~Sequelize.html#instance-constructor-constructor --- database/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/database/index.ts b/database/index.ts index 058df9c..27dcb1f 100644 --- a/database/index.ts +++ b/database/index.ts @@ -10,7 +10,6 @@ const sequelize = new Sequelize({ username, password, host: process.env.HOST, - native: false, dialect: 'postgres', logging: false, dialectModule: require('pg'), From b565109c5a90e58ca0ef37c9df371904eef9bd2e Mon Sep 17 00:00:00 2001 From: Finn Woelm Date: Sat, 22 Aug 2020 08:05:54 +0200 Subject: [PATCH 8/9] Uncomment console.log in database There were some remarks about console.logs causing issues with pg-native, so I temporarily commented-out the console.logs. Anyway, these console.logs do not seem to be an issue. See: https://github.com/sequelize/sequelize/issues/3781#issuecomment-421282703 --- database/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database/index.ts b/database/index.ts index 27dcb1f..a039601 100644 --- a/database/index.ts +++ b/database/index.ts @@ -39,9 +39,9 @@ const db = { (async () => { try { await sequelize.authenticate(); - // console.log('Database connection has been established successfully.'); + console.log('Database connection has been established successfully.'); } catch (error) { - // console.error('Unable to connect to the database:', error); + console.error('Unable to connect to the database:', error); } })(); From a8f110b686eeed269c39152bc291c7cd40ecd4c4 Mon Sep 17 00:00:00 2001 From: Finn Woelm Date: Sat, 22 Aug 2020 08:05:54 +0200 Subject: [PATCH 9/9] Improve webpack comments Improve documentation for webpack settings in next.config.js --- next.config.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/next.config.js b/next.config.js index f15d403..ec78a63 100644 --- a/next.config.js +++ b/next.config.js @@ -2,8 +2,10 @@ module.exports = { // Target must be serverless target: 'serverless', webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => { - // Note: we provide webpack above so you should not `require` it - // Perform customizations to webpack config + // Note: webpack is provided, so we do not need to `require` it + + // Do not include .native which tries to load pg-native + // See: https://github.com/sequelize/sequelize/issues/3781#issuecomment-537979334 config.plugins.push(new webpack.IgnorePlugin(/.\/native/)) // Important: return the modified config