fix: mysql + sqlite incompatible queries

pull/621/head
Nicolas Giard 6 years ago
parent 65f1611741
commit 96f4e89020

3
.gitignore vendored

@ -29,6 +29,7 @@ npm-debug.log*
/repo /repo
/data /data
/uploads /uploads
*.sqlite
# IDE exclude # IDE exclude
.idea .idea
@ -38,4 +39,4 @@ npm-debug.log*
test-results/ test-results/
# Localization Resources # Localization Resources
/server/locales/**/*.yml /server/locales/**/*.yml

@ -48,7 +48,7 @@
br br
| Should you have any question or would like to report something that doesn't look right, feel free to create a new issue on the #[a(href='https://github.com/Requarks/wiki/issues') GitHub project]. | Should you have any question or would like to report something that doesn't look right, feel free to create a new issue on the #[a(href='https://github.com/Requarks/wiki/issues') GitHub project].
.body-1.pt-3 .body-1.pt-3
svg.icons.is-18.is-outlined.has-right-pad.is-text: use(xlink:href='#nc-cd-reader') v-icon.mr-2 system_update
span You are about to install Wiki.js #[strong {{wikiVersion}}]. span You are about to install Wiki.js #[strong {{wikiVersion}}].
v-divider.mt-3 v-divider.mt-3
v-form v-form

@ -1,6 +1,7 @@
@import "global"; @import "global";
@import "base/base"; @import "base/base";
@import "base/icons";
@import "../libs/animate/animate"; @import "../libs/animate/animate";

@ -0,0 +1,33 @@
.icons {
display: inline-block;
color: mc('grey', '800');
&.is-text {
display: inline-block;
width: 1em;
height: 1em;
vertical-align: middle;
position: relative;
top: -0.0625em;
stroke: none;
fill: none;
}
@each $size in 16,18,20,24,32,48,64,96,128 {
&.is-#{$size} {
width: #{$size}px;
height: #{$size}px;
}
}
&.has-right-pad {
margin-right: .5rem;
}
&.is-outlined {
stroke-width: 2px;
use {
fill: inherit;
stroke: mc('grey', '800');
}
}
}
.material-design-icon {
display: inline-flex;
}

@ -23,7 +23,7 @@ paths:
# --------------------------------------------------------------------- # ---------------------------------------------------------------------
# Supported Database Engines: # Supported Database Engines:
# - postgres = PostgreSQL 9.5 or later # - postgres = PostgreSQL 9.5 or later
# - mysql = MySQL 8.0 / MariaDB 10.2.7 or later # - mysql = MySQL 5.7.8 / MariaDB 10.2.7 or later
# - mssql = MS SQL Server 2012 or later # - mssql = MS SQL Server 2012 or later
# - sqlite = SQLite 3.9 or later # - sqlite = SQLite 3.9 or later

@ -37,15 +37,15 @@
"node": ">=8.11" "node": ">=8.11"
}, },
"dependencies": { "dependencies": {
"apollo-server": "2.0.0", "apollo-server": "2.0.2",
"apollo-server-express": "2.0.0", "apollo-server-express": "2.0.2",
"auto-load": "3.0.0", "auto-load": "3.0.0",
"axios": "0.18.0", "axios": "0.18.0",
"bcryptjs-then": "1.0.1", "bcryptjs-then": "1.0.1",
"bluebird": "3.5.1", "bluebird": "3.5.1",
"body-parser": "1.18.3", "body-parser": "1.18.3",
"bugsnag": "2.4.3", "bugsnag": "2.4.3",
"bull": "3.4.4", "bull": "3.4.7",
"chalk": "2.4.1", "chalk": "2.4.1",
"cheerio": "1.0.0-rc.2", "cheerio": "1.0.0-rc.2",
"child-process-promise": "2.2.1", "child-process-promise": "2.2.1",
@ -62,20 +62,20 @@
"express-brute": "1.0.1", "express-brute": "1.0.1",
"express-brute-redis": "0.0.1", "express-brute-redis": "0.0.1",
"express-session": "1.15.6", "express-session": "1.15.6",
"file-type": "8.1.0", "file-type": "9.0.0",
"filesize.js": "1.0.2", "filesize.js": "1.0.2",
"follow-redirects": "1.5.2", "follow-redirects": "1.5.5",
"fs-extra": "7.0.0", "fs-extra": "7.0.0",
"getos": "3.1.0", "getos": "3.1.0",
"graphql": "0.13.2", "graphql": "0.13.2",
"graphql-list-fields": "2.0.2", "graphql-list-fields": "2.0.2",
"graphql-tools": "3.1.1", "graphql-tools": "3.1.1",
"i18next": "11.5.0", "i18next": "11.6.0",
"i18next-express-middleware": "1.2.1", "i18next-express-middleware": "1.2.1",
"i18next-localstorage-cache": "1.1.1", "i18next-localstorage-cache": "1.1.1",
"i18next-node-fs-backend": "1.2.1", "i18next-node-fs-backend": "1.2.1",
"image-size": "0.6.3", "image-size": "0.6.3",
"ioredis": "3.2.2", "ioredis": "4.0.0",
"js-yaml": "3.12.0", "js-yaml": "3.12.0",
"jsonwebtoken": "8.3.0", "jsonwebtoken": "8.3.0",
"klaw": "3.0.0", "klaw": "3.0.0",
@ -99,7 +99,7 @@
"mime-types": "2.1.19", "mime-types": "2.1.19",
"moment": "2.22.2", "moment": "2.22.2",
"moment-timezone": "0.5.21", "moment-timezone": "0.5.21",
"mongodb": "3.1.1", "mongodb": "3.1.3",
"mssql": "4.1.0", "mssql": "4.1.0",
"multer": "1.3.1", "multer": "1.3.1",
"mysql2": "1.6.1", "mysql2": "1.6.1",
@ -133,7 +133,7 @@
"raven": "2.6.3", "raven": "2.6.3",
"read-chunk": "2.1.0", "read-chunk": "2.1.0",
"remove-markdown": "0.3.0", "remove-markdown": "0.3.0",
"request": "2.87.0", "request": "2.88.0",
"request-promise": "4.2.2", "request-promise": "4.2.2",
"scim-query-filter-parser": "1.1.0", "scim-query-filter-parser": "1.1.0",
"semver": "5.5.0", "semver": "5.5.0",
@ -147,16 +147,16 @@
}, },
"devDependencies": { "devDependencies": {
"@panter/vue-i18next": "0.12.0", "@panter/vue-i18next": "0.12.0",
"@vue/cli": "3.0.0-rc.11", "@vue/cli": "3.0.0",
"apollo-cache-inmemory": "1.2.6", "apollo-cache-inmemory": "1.2.7",
"apollo-client": "2.3.7", "apollo-client": "2.3.8",
"apollo-fetch": "0.7.0", "apollo-fetch": "0.7.0",
"apollo-link": "1.2.2", "apollo-link": "1.2.2",
"apollo-link-batch-http": "1.2.2", "apollo-link-batch-http": "1.2.2",
"apollo-link-error": "1.1.0", "apollo-link-error": "1.1.0",
"apollo-link-http": "1.5.4", "apollo-link-http": "1.5.4",
"apollo-link-persisted-queries": "0.2.1", "apollo-link-persisted-queries": "0.2.1",
"autoprefixer": "9.1.0", "autoprefixer": "9.1.1",
"babel-cli": "6.26.0", "babel-cli": "6.26.0",
"babel-core": "6.26.3", "babel-core": "6.26.3",
"babel-eslint": "8.2.6", "babel-eslint": "8.2.6",
@ -180,7 +180,7 @@
"eslint": "5.3.0", "eslint": "5.3.0",
"eslint-config-requarks": "1.0.7", "eslint-config-requarks": "1.0.7",
"eslint-config-standard": "11.0.0", "eslint-config-standard": "11.0.0",
"eslint-plugin-import": "2.13.0", "eslint-plugin-import": "2.14.0",
"eslint-plugin-node": "7.0.1", "eslint-plugin-node": "7.0.1",
"eslint-plugin-promise": "3.8.0", "eslint-plugin-promise": "3.8.0",
"eslint-plugin-standard": "3.1.0", "eslint-plugin-standard": "3.1.0",
@ -195,19 +195,19 @@
"html-webpack-pug-plugin": "0.3.0", "html-webpack-pug-plugin": "0.3.0",
"i18next-xhr-backend": "1.5.1", "i18next-xhr-backend": "1.5.1",
"ignore-loader": "0.1.2", "ignore-loader": "0.1.2",
"jest": "23.4.2", "jest": "23.5.0",
"jest-junit": "5.1.0", "jest-junit": "5.1.0",
"js-cookie": "2.2.0", "js-cookie": "2.2.0",
"lodash-webpack-plugin": "0.11.5", "lodash-webpack-plugin": "0.11.5",
"mini-css-extract-plugin": "0.4.1", "mini-css-extract-plugin": "0.4.1",
"node-sass": "4.9.2", "node-sass": "4.9.3",
"offline-plugin": "5.0.5", "offline-plugin": "5.0.5",
"optimize-css-assets-webpack-plugin": "5.0.0", "optimize-css-assets-webpack-plugin": "5.0.0",
"postcss-cssnext": "3.1.0", "postcss-cssnext": "3.1.0",
"postcss-flexbugs-fixes": "4.1.0", "postcss-flexbugs-fixes": "4.1.0",
"postcss-flexibility": "2.0.0", "postcss-flexibility": "2.0.0",
"postcss-import": "12.0.0", "postcss-import": "12.0.0",
"postcss-loader": "2.1.6", "postcss-loader": "3.0.0",
"postcss-preset-env": "5.3.0", "postcss-preset-env": "5.3.0",
"postcss-selector-parser": "5.0.0-rc.3", "postcss-selector-parser": "5.0.0-rc.3",
"pug-lint": "2.5.0", "pug-lint": "2.5.0",
@ -224,7 +224,7 @@
"stylus": "0.54.5", "stylus": "0.54.5",
"stylus-loader": "3.0.2", "stylus-loader": "3.0.2",
"twemoji-awesome": "1.0.6", "twemoji-awesome": "1.0.6",
"url-loader": "1.0.1", "url-loader": "1.1.0",
"vee-validate": "2.1.0-beta.7", "vee-validate": "2.1.0-beta.7",
"velocity-animate": "1.5.2", "velocity-animate": "1.5.2",
"vue": "2.5.17", "vue": "2.5.17",
@ -243,7 +243,7 @@
"vue-tour": "1.0.1", "vue-tour": "1.0.1",
"vue-tree-navigation": "3.0.1", "vue-tree-navigation": "3.0.1",
"vuedraggable": "2.16.0", "vuedraggable": "2.16.0",
"vuetify": "1.1.10", "vuetify": "1.1.12",
"vuex": "3.0.1", "vuex": "3.0.1",
"vuex-pathify": "1.1.3", "vuex-pathify": "1.1.3",
"vuex-persistedstate": "2.5.4", "vuex-persistedstate": "2.5.4",

@ -8,7 +8,7 @@ const Objection = require('objection')
/* global WIKI */ /* global WIKI */
/** /**
* PostgreSQL DB module * ORM DB module
*/ */
module.exports = { module.exports = {
Objection, Objection,
@ -22,13 +22,12 @@ module.exports = {
let self = this let self = this
let dbClient = null let dbClient = null
const dbConfig = (!_.isEmpty(process.env.WIKI_DB_CONNSTR)) ? process.env.WIKI_DB_CONNSTR : { let dbConfig = (!_.isEmpty(process.env.WIKI_DB_CONNSTR)) ? process.env.WIKI_DB_CONNSTR : {
host: WIKI.config.db.host, host: WIKI.config.db.host,
user: WIKI.config.db.user, user: WIKI.config.db.user,
password: WIKI.config.db.pass, password: WIKI.config.db.pass,
database: WIKI.config.db.db, database: WIKI.config.db.db,
port: WIKI.config.db.port, port: WIKI.config.db.port
filename: WIKI.config.db.storage
} }
switch (WIKI.config.db.type) { switch (WIKI.config.db.type) {
@ -43,6 +42,7 @@ module.exports = {
break break
case 'sqlite': case 'sqlite':
dbClient = 'sqlite3' dbClient = 'sqlite3'
dbConfig = { filename: WIKI.config.db.storage }
break break
default: default:
WIKI.logger.error('Invalid DB Type') WIKI.logger.error('Invalid DB Type')

@ -12,7 +12,7 @@ exports.up = knex => {
table.enum('kind', ['binary', 'image']).notNullable().defaultTo('binary') table.enum('kind', ['binary', 'image']).notNullable().defaultTo('binary')
table.string('mime').notNullable().defaultTo('application/octet-stream') table.string('mime').notNullable().defaultTo('application/octet-stream')
table.integer('fileSize').unsigned().comment('In kilobytes') table.integer('fileSize').unsigned().comment('In kilobytes')
table.jsonb('metadata') table.json('metadata')
table.string('createdAt').notNullable() table.string('createdAt').notNullable()
table.string('updatedAt').notNullable() table.string('updatedAt').notNullable()
}) })
@ -28,10 +28,10 @@ exports.up = knex => {
table.increments('id').primary() table.increments('id').primary()
table.string('key').notNullable().unique() table.string('key').notNullable().unique()
table.boolean('isEnabled').notNullable().defaultTo(false) table.boolean('isEnabled').notNullable().defaultTo(false)
table.jsonb('config').notNullable() table.json('config').notNullable()
table.boolean('selfRegistration').notNullable().defaultTo(false) table.boolean('selfRegistration').notNullable().defaultTo(false)
table.jsonb('domainWhitelist').notNullable() table.json('domainWhitelist').notNullable()
table.jsonb('autoEnrollGroups').notNullable() table.json('autoEnrollGroups').notNullable()
}) })
// COMMENTS ---------------------------- // COMMENTS ----------------------------
.createTable('comments', table => { .createTable('comments', table => {
@ -45,7 +45,7 @@ exports.up = knex => {
table.increments('id').primary() table.increments('id').primary()
table.string('key').notNullable().unique() table.string('key').notNullable().unique()
table.boolean('isEnabled').notNullable().defaultTo(false) table.boolean('isEnabled').notNullable().defaultTo(false)
table.jsonb('config').notNullable() table.json('config').notNullable()
}) })
// GROUPS ------------------------------ // GROUPS ------------------------------
.createTable('groups', table => { .createTable('groups', table => {
@ -58,7 +58,7 @@ exports.up = knex => {
.createTable('locales', table => { .createTable('locales', table => {
table.increments('id').primary() table.increments('id').primary()
table.string('code', 2).notNullable().unique() table.string('code', 2).notNullable().unique()
table.jsonb('strings') table.json('strings')
table.boolean('isRTL').notNullable().defaultTo(false) table.boolean('isRTL').notNullable().defaultTo(false)
table.string('name').notNullable() table.string('name').notNullable()
table.string('nativeName').notNullable() table.string('nativeName').notNullable()
@ -99,7 +99,7 @@ exports.up = knex => {
.createTable('settings', table => { .createTable('settings', table => {
table.increments('id').primary() table.increments('id').primary()
table.string('key').notNullable().unique() table.string('key').notNullable().unique()
table.jsonb('value') table.json('value')
table.string('updatedAt').notNullable() table.string('updatedAt').notNullable()
}) })
// STORAGE ----------------------------- // STORAGE -----------------------------
@ -108,7 +108,7 @@ exports.up = knex => {
table.string('key').notNullable().unique() table.string('key').notNullable().unique()
table.boolean('isEnabled').notNullable().defaultTo(false) table.boolean('isEnabled').notNullable().defaultTo(false)
table.enum('mode', ['sync', 'push', 'pull']).notNullable().defaultTo('push') table.enum('mode', ['sync', 'push', 'pull']).notNullable().defaultTo('push')
table.jsonb('config') table.json('config')
}) })
// TAGS -------------------------------- // TAGS --------------------------------
.createTable('tags', table => { .createTable('tags', table => {

@ -40,6 +40,7 @@ module.exports = class Authentication extends Model {
} }
static async refreshStrategiesFromDisk() { static async refreshStrategiesFromDisk() {
let trx
try { try {
const dbStrategies = await WIKI.models.authentication.query() const dbStrategies = await WIKI.models.authentication.query()
@ -82,7 +83,11 @@ module.exports = class Authentication extends Model {
} }
} }
if (newStrategies.length > 0) { if (newStrategies.length > 0) {
await WIKI.models.authentication.query().insert(newStrategies) trx = await WIKI.models.Objection.transaction.start(WIKI.models.knex)
for (let strategy of newStrategies) {
await WIKI.models.authentication.query(trx).insert(strategy)
}
await trx.commit()
WIKI.logger.info(`Loaded ${newStrategies.length} new authentication strategies: [ OK ]`) WIKI.logger.info(`Loaded ${newStrategies.length} new authentication strategies: [ OK ]`)
} else { } else {
WIKI.logger.info(`No new authentication strategies found: [ SKIPPED ]`) WIKI.logger.info(`No new authentication strategies found: [ SKIPPED ]`)
@ -90,6 +95,9 @@ module.exports = class Authentication extends Model {
} catch (err) { } catch (err) {
WIKI.logger.error(`Failed to scan or load new authentication providers: [ FAILED ]`) WIKI.logger.error(`Failed to scan or load new authentication providers: [ FAILED ]`)
WIKI.logger.error(err) WIKI.logger.error(err)
if (trx) {
trx.rollback()
}
} }
} }
} }

@ -33,6 +33,7 @@ module.exports = class Storage extends Model {
} }
static async refreshTargetsFromDisk() { static async refreshTargetsFromDisk() {
let trx
try { try {
const dbTargets = await WIKI.models.storage.query() const dbTargets = await WIKI.models.storage.query()
@ -74,7 +75,11 @@ module.exports = class Storage extends Model {
} }
} }
if (newTargets.length > 0) { if (newTargets.length > 0) {
await WIKI.models.storage.query().insert(newTargets) trx = await WIKI.models.Objection.transaction.start(WIKI.models.knex)
for (let target of newTargets) {
await WIKI.models.storage.query(trx).insert(target)
}
await trx.commit()
WIKI.logger.info(`Loaded ${newTargets.length} new storage targets: [ OK ]`) WIKI.logger.info(`Loaded ${newTargets.length} new storage targets: [ OK ]`)
} else { } else {
WIKI.logger.info(`No new storage targets found: [ SKIPPED ]`) WIKI.logger.info(`No new storage targets found: [ SKIPPED ]`)
@ -82,6 +87,9 @@ module.exports = class Storage extends Model {
} catch (err) { } catch (err) {
WIKI.logger.error(`Failed to scan or load new storage providers: [ FAILED ]`) WIKI.logger.error(`Failed to scan or load new storage providers: [ FAILED ]`)
WIKI.logger.error(err) WIKI.logger.error(err)
if (trx) {
trx.rollback()
}
} }
} }

@ -70,7 +70,7 @@ module.exports = () => {
app.get('*', async (req, res) => { app.get('*', async (req, res) => {
let packageObj = await fs.readJson(path.join(WIKI.ROOTPATH, 'package.json')) let packageObj = await fs.readJson(path.join(WIKI.ROOTPATH, 'package.json'))
res.render('main/setup', { res.render('setup', {
packageObj, packageObj,
telemetryClientID: WIKI.telemetry.cid telemetryClientID: WIKI.telemetry.cid
}) })

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save