Merge pull request #342 from halkeye/postgresql

Add postgresql support
This commit is contained in:
Travis Ralston 2020-04-22 15:01:06 -06:00 committed by GitHub
commit 3e8ad80fc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 61 additions and 33 deletions

View File

@ -24,7 +24,7 @@ ENV PATH=/home/node/.npm-global/bin:$PATH
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
RUN cd /home/node/matrix-dimension && \
npm install -D wd rimraf webpack webpack-command sqlite3 && \
npm install -D wd rimraf webpack webpack-command sqlite3 pg pg-hstore && \
NODE_ENV=production npm run-script build:web && npm run-script build:app
USER root

59
package-lock.json generated
View File

@ -3631,9 +3631,9 @@
}
},
"dottie": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.1.tgz",
"integrity": "sha512-ch5OQgvGDK2u8pSZeSYAQaV/lczImd7pMJ7BcEPXmnFVjy4yJIzP6CsODJUTH8mg1tyH1Z2abOiuJO3DjZ/GBw=="
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.2.tgz",
"integrity": "sha512-fmrwR04lsniq/uSr8yikThDTrM7epXHBAAjH9TbeH3rEA8tdCO7mRzB9hdmdGyJCxF8KERo9CITcm3kGuoyMhg=="
},
"duplexify": {
"version": "3.7.1",
@ -4557,7 +4557,8 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"aproba": {
"version": "1.2.0",
@ -4578,12 +4579,14 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -4598,17 +4601,20 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"core-util-is": {
"version": "1.0.2",
@ -4725,7 +4731,8 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"ini": {
"version": "1.3.5",
@ -4737,6 +4744,7 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@ -4751,6 +4759,7 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@ -4758,12 +4767,14 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"minipass": {
"version": "2.3.5",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@ -4782,6 +4793,7 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
@ -4862,7 +4874,8 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"object-assign": {
"version": "4.1.1",
@ -4874,6 +4887,7 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@ -4959,7 +4973,8 @@
"safe-buffer": {
"version": "5.1.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"safer-buffer": {
"version": "2.1.2",
@ -4995,6 +5010,7 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@ -5014,6 +5030,7 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@ -5057,12 +5074,14 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"yallist": {
"version": "3.0.3",
"bundled": true,
"dev": true
"dev": true,
"optional": true
}
}
},
@ -6941,9 +6960,9 @@
"integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg=="
},
"moment-timezone": {
"version": "0.5.27",
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.27.tgz",
"integrity": "sha512-EIKQs7h5sAsjhPCqN6ggx6cEbs94GK050254TIJySD1bzoM5JTYDwAU1IoVOeTOL6Gm27kYJ51/uuvq1kIlrbw==",
"version": "0.5.28",
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.28.tgz",
"integrity": "sha512-TDJkZvAyKIVWg5EtVqRzU97w0Rb0YVbfpqyjgu6GwXCAohVRqwZjf4fOzDE6p1Ch98Sro/8hQQi65WDXW5STPw==",
"requires": {
"moment": ">= 2.9.0"
}
@ -10481,9 +10500,9 @@
}
},
"sequelize": {
"version": "5.15.1",
"resolved": "https://registry.npmjs.org/sequelize/-/sequelize-5.15.1.tgz",
"integrity": "sha512-DCzzJYvJLMKnyf8G3at2A+yM9M2fSQmTmuOYIpCWM8Gjqx3XfgNTd1NkuyPWFoi1/d1AXQsN2VDPXkPczida8A==",
"version": "5.18.4",
"resolved": "https://registry.npmjs.org/sequelize/-/sequelize-5.18.4.tgz",
"integrity": "sha512-bBmJqpO1H8Z7L0xzITqVo5KHXFI7GmKfGl/5SIPDKsuUMbuZT98s+gyGeaLXpOWGH1ZUO79hvJ8z74vNcxBWHg==",
"requires": {
"bluebird": "^3.5.0",
"cls-bluebird": "^2.1.0",

View File

@ -44,7 +44,7 @@
"request-promise": "^4.2.4",
"require-dir-all": "^0.4.15",
"semver": "^6.0.0",
"sequelize": "^5.15.1",
"sequelize": "^5.18.4",
"sequelize-typescript": "^1.0.0",
"sharp": "^0.21.1",
"split-host": "^0.1.1",

View File

@ -17,6 +17,7 @@ export interface DimensionConfig {
database: {
file: string;
botData: string;
uri: string;
};
admins: string[];
goneb: {
@ -38,4 +39,4 @@ export interface DimensionConfig {
logging: LogConfig;
}
export default <DimensionConfig>config;
export default <DimensionConfig>config;

View File

@ -35,14 +35,20 @@ class _DimensionStore {
private sequelize: Sequelize;
constructor() {
this.sequelize = new Sequelize({
dialect: 'sqlite',
database: "dimension",
storage: process.env['DIMENSION_DB_PATH'] || config.database.file,
username: "",
password: "",
logging: i => LogService.verbose("DimensionStore [SQL]", i)
});
if (process.env.DATABASE_URI || config.database.uri ) {
this.sequelize = new Sequelize(process.env.DATABASE_URI || config.database.uri , {
logging: i => LogService.verbose("DimensionStore [SQL]", i)
});
} else {
this.sequelize = new Sequelize({
dialect: 'sqlite',
database: "dimension",
storage: process.env['DIMENSION_DB_PATH'] || config.database.file,
username: "",
password: "",
logging: i => LogService.verbose("DimensionStore [SQL]", i)
});
}
this.sequelize.addModels([
User,
UserScalarToken,

View File

@ -18,7 +18,9 @@ export default {
licensePath: "/licenses/cc_by-nc_4.0.txt",
}
]))
.then(packId => {
.then(() => queryInterface.rawSelect('dimension_sticker_packs', { where: { name: "Loading Artist" } }, ['id']))
.then(packIds => {
const packId = Array.isArray(packIds) ? packIds[0] : packIds;
return queryInterface.bulkInsert("dimension_stickers", [
{
packId: packId,
@ -446,4 +448,4 @@ export default {
down: (_queryInterface: QueryInterface) => {
throw new Error("there is no going back");
}
}
}