Commit 92d0925d authored by Nicolas Giard's avatar Nicolas Giard

fix: mssql initial migration crash

parent e2848228
...@@ -125,7 +125,7 @@ export default { ...@@ -125,7 +125,7 @@ export default {
metaRobots: ['Index', 'Follow', 'No Index', 'No Follow'], metaRobots: ['Index', 'Follow', 'No Index', 'No Follow'],
useSquareLogo: false, useSquareLogo: false,
displayMascot: true, displayMascot: true,
featurePageRatings: false, featurePageRatings: true,
featurePersonalWiki: true featurePersonalWiki: true
} }
}, },
......
...@@ -97,11 +97,13 @@ ...@@ -97,11 +97,13 @@
v-avatar.indigo.darken-1(size='40') v-avatar.indigo.darken-1(size='40')
icon-database(fillColor='#FFFFFF') icon-database(fillColor='#FFFFFF')
v-list-tile-content v-list-tile-content
v-list-tile-title {{ info.dbVersion }} v-list-tile-title(v-html='dbVersion')
v-list-tile-sub-title {{ info.dbHost }} v-list-tile-sub-title {{ info.dbHost }}
</template> </template>
<script> <script>
import _ from 'lodash'
import IconCube from 'mdi/cube' import IconCube from 'mdi/cube'
import IconDatabase from 'mdi/database' import IconDatabase from 'mdi/database'
import IconNodeJs from 'mdi/nodejs' import IconNodeJs from 'mdi/nodejs'
...@@ -119,6 +121,11 @@ export default { ...@@ -119,6 +121,11 @@ export default {
info: {} info: {}
} }
}, },
computed: {
dbVersion() {
return _.get(this.info, 'dbVersion', '').replace(/(?:\r\n|\r|\n)/g, '<br />')
}
},
methods: { methods: {
async refresh() { async refresh() {
await this.$apollo.queries.info.refetch() await this.$apollo.queries.info.refetch()
......
...@@ -22,7 +22,8 @@ bindIP: 0.0.0.0 ...@@ -22,7 +22,8 @@ bindIP: 0.0.0.0
# --------------------------------------------------------------------- # ---------------------------------------------------------------------
# Supported Database Engines: # Supported Database Engines:
# - postgres = PostgreSQL 9.5 or later # - postgres = PostgreSQL 9.5 or later
# - mysql = MySQL 5.7.8 / MariaDB 10.2.7 or later # - mysql = MySQL 5.7.8
# - mariadb = 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
......
FROM node:8-alpine FROM node:10-alpine
LABEL maintainer="requarks.io" LABEL maintainer="requarks.io"
RUN apk update && \ RUN apk update && \
......
# -- DEV DOCKERFILE -- # -- DEV DOCKERFILE --
# -- DO NOT USE IN PRODUCTION! -- # -- DO NOT USE IN PRODUCTION! --
FROM node:8-alpine FROM node:10-alpine
LABEL maintainer "requarks.io" LABEL maintainer "requarks.io"
RUN apk update && \ RUN apk update && \
......
...@@ -39,11 +39,11 @@ ...@@ -39,11 +39,11 @@
}, },
"homepage": "https://github.com/Requarks/wiki#readme", "homepage": "https://github.com/Requarks/wiki#readme",
"engines": { "engines": {
"node": ">=8.11" "node": ">=10.10"
}, },
"dependencies": { "dependencies": {
"apollo-server": "2.0.6", "apollo-server": "2.0.7",
"apollo-server-express": "2.0.5", "apollo-server-express": "2.0.6",
"auto-load": "3.0.1", "auto-load": "3.0.1",
"axios": "0.18.0", "axios": "0.18.0",
"bcryptjs-then": "1.0.1", "bcryptjs-then": "1.0.1",
...@@ -72,15 +72,16 @@ ...@@ -72,15 +72,16 @@
"follow-redirects": "1.5.7", "follow-redirects": "1.5.7",
"fs-extra": "7.0.0", "fs-extra": "7.0.0",
"getos": "3.1.0", "getos": "3.1.0",
"graphql": "14.0.0", "graphql": "14.0.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.6.0", "i18next": "11.7.0",
"i18next-express-middleware": "1.3.2", "i18next-express-middleware": "1.3.2",
"i18next-localstorage-cache": "1.1.1", "i18next-localstorage-cache": "1.1.1",
"i18next-node-fs-backend": "2.0.0", "i18next-node-fs-backend": "2.1.0",
"image-size": "0.6.3", "image-size": "0.6.3",
"ioredis": "4.0.0", "ioredis": "4.0.0",
"js-binary": "1.2.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",
...@@ -136,7 +137,7 @@ ...@@ -136,7 +137,7 @@
"pm2": "3.0.4", "pm2": "3.0.4",
"pug": "2.0.3", "pug": "2.0.3",
"qr-image": "3.2.0", "qr-image": "3.2.0",
"raven": "2.6.3", "raven": "2.6.4",
"read-chunk": "3.0.0", "read-chunk": "3.0.0",
"remove-markdown": "0.3.0", "remove-markdown": "0.3.0",
"request": "2.88.0", "request": "2.88.0",
...@@ -148,8 +149,8 @@ ...@@ -148,8 +149,8 @@
"uuid": "3.3.2", "uuid": "3.3.2",
"validator": "10.7.1", "validator": "10.7.1",
"validator-as-promised": "1.0.2", "validator-as-promised": "1.0.2",
"winston": "3.0.0", "winston": "3.1.0",
"yargs": "12.0.1" "yargs": "12.0.2"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.0.0", "@babel/cli": "^7.0.0",
...@@ -176,13 +177,13 @@ ...@@ -176,13 +177,13 @@
"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.3", "autoprefixer": "9.1.5",
"babel-eslint": "9.0.0", "babel-eslint": "9.0.0",
"babel-jest": "23.4.2", "babel-jest": "23.4.2",
"babel-loader": "^8.0.0", "babel-loader": "^8.0.0",
"babel-plugin-graphql-tag": "1.6.0", "babel-plugin-graphql-tag": "1.6.0",
"babel-plugin-lodash": "3.3.4", "babel-plugin-lodash": "3.3.4",
"babel-plugin-transform-imports": "1.5.0", "babel-plugin-transform-imports": "1.5.1",
"brace": "0.11.1", "brace": "0.11.1",
"cache-loader": "1.2.2", "cache-loader": "1.2.2",
"chart.js": "2.7.2", "chart.js": "2.7.2",
...@@ -197,7 +198,7 @@ ...@@ -197,7 +198,7 @@
"eslint-config-standard": "12.0.0", "eslint-config-standard": "12.0.0",
"eslint-plugin-import": "2.14.0", "eslint-plugin-import": "2.14.0",
"eslint-plugin-node": "7.0.1", "eslint-plugin-node": "7.0.1",
"eslint-plugin-promise": "4.0.0", "eslint-plugin-promise": "4.0.1",
"eslint-plugin-standard": "4.0.0", "eslint-plugin-standard": "4.0.0",
"eslint-plugin-vue": "4.7.1", "eslint-plugin-vue": "4.7.1",
"file-loader": "2.0.0", "file-loader": "2.0.0",
...@@ -226,8 +227,8 @@ ...@@ -226,8 +227,8 @@
"pug-loader": "2.4.0", "pug-loader": "2.4.0",
"pug-plain-loader": "1.0.0", "pug-plain-loader": "1.0.0",
"raw-loader": "0.5.1", "raw-loader": "0.5.1",
"react": "16.4.2", "react": "16.5.0",
"react-dom": "16.4.2", "react-dom": "16.5.0",
"sass-loader": "7.1.0", "sass-loader": "7.1.0",
"sass-resources-loader": "1.3.3", "sass-resources-loader": "1.3.3",
"script-ext-html-webpack-plugin": "2.0.1", "script-ext-html-webpack-plugin": "2.0.1",
...@@ -240,7 +241,7 @@ ...@@ -240,7 +241,7 @@
"vee-validate": "2.1.0-beta.8", "vee-validate": "2.1.0-beta.8",
"velocity-animate": "1.5.2", "velocity-animate": "1.5.2",
"vue": "2.5.17", "vue": "2.5.17",
"vue-apollo": "3.0.0-beta.21", "vue-apollo": "3.0.0-beta.24",
"vue-chartjs": "3.4.0", "vue-chartjs": "3.4.0",
"vue-clipboards": "1.2.4", "vue-clipboards": "1.2.4",
"vue-codemirror": "4.0.5", "vue-codemirror": "4.0.5",
...@@ -255,7 +256,7 @@ ...@@ -255,7 +256,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.2.1", "vuetify": "1.2.3",
"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",
...@@ -266,8 +267,8 @@ ...@@ -266,8 +267,8 @@
"webpack-hot-middleware": "2.23.1", "webpack-hot-middleware": "2.23.1",
"webpack-merge": "4.1.4", "webpack-merge": "4.1.4",
"whatwg-fetch": "2.0.4", "whatwg-fetch": "2.0.4",
"write-file-webpack-plugin": "4.3.2", "write-file-webpack-plugin": "4.4.0",
"xterm": "3.6.0" "xterm": "3.7.0"
}, },
"browserslist": [ "browserslist": [
"> 1%", "> 1%",
......
...@@ -34,6 +34,7 @@ module.exports = { ...@@ -34,6 +34,7 @@ module.exports = {
case 'postgres': case 'postgres':
dbClient = 'pg' dbClient = 'pg'
break break
case 'mariadb':
case 'mysql': case 'mysql':
dbClient = 'mysql2' dbClient = 'mysql2'
break break
...@@ -52,6 +53,7 @@ module.exports = { ...@@ -52,6 +53,7 @@ module.exports = {
this.knex = Knex({ this.knex = Knex({
client: dbClient, client: dbClient,
useNullAsDefault: true, useNullAsDefault: true,
asyncStackTraces: WIKI.IS_DEBUG,
connection: dbConfig, connection: dbConfig,
pool: { pool: {
async afterCreate(conn, done) { async afterCreate(conn, done) {
......
...@@ -25,8 +25,7 @@ exports.up = knex => { ...@@ -25,8 +25,7 @@ exports.up = knex => {
}) })
// AUTHENTICATION ---------------------- // AUTHENTICATION ----------------------
.createTable('authentication', table => { .createTable('authentication', table => {
table.increments('id').primary() table.string('key').notNullable().primary()
table.string('key').notNullable().unique()
table.boolean('isEnabled').notNullable().defaultTo(false) table.boolean('isEnabled').notNullable().defaultTo(false)
table.json('config').notNullable() table.json('config').notNullable()
table.boolean('selfRegistration').notNullable().defaultTo(false) table.boolean('selfRegistration').notNullable().defaultTo(false)
...@@ -42,8 +41,7 @@ exports.up = knex => { ...@@ -42,8 +41,7 @@ exports.up = knex => {
}) })
// EDITORS ----------------------------- // EDITORS -----------------------------
.createTable('editors', table => { .createTable('editors', table => {
table.increments('id').primary() table.string('key').notNullable().primary()
table.string('key').notNullable().unique()
table.boolean('isEnabled').notNullable().defaultTo(false) table.boolean('isEnabled').notNullable().defaultTo(false)
table.json('config').notNullable() table.json('config').notNullable()
}) })
...@@ -56,8 +54,7 @@ exports.up = knex => { ...@@ -56,8 +54,7 @@ exports.up = knex => {
}) })
// LOCALES ----------------------------- // LOCALES -----------------------------
.createTable('locales', table => { .createTable('locales', table => {
table.increments('id').primary() table.string('code', 2).notNullable().primary()
table.string('code', 2).notNullable().unique()
table.json('strings') table.json('strings')
table.boolean('isRTL').notNullable().defaultTo(false) table.boolean('isRTL').notNullable().defaultTo(false)
table.string('name').notNullable() table.string('name').notNullable()
...@@ -67,8 +64,7 @@ exports.up = knex => { ...@@ -67,8 +64,7 @@ exports.up = knex => {
}) })
// LOGGING ---------------------------- // LOGGING ----------------------------
.createTable('loggers', table => { .createTable('loggers', table => {
table.increments('id').primary() table.string('key').notNullable().primary()
table.string('key').notNullable().unique()
table.boolean('isEnabled').notNullable().defaultTo(false) table.boolean('isEnabled').notNullable().defaultTo(false)
table.string('level').notNullable().defaultTo('warn') table.string('level').notNullable().defaultTo('warn')
table.json('config') table.json('config')
...@@ -106,29 +102,25 @@ exports.up = knex => { ...@@ -106,29 +102,25 @@ exports.up = knex => {
}) })
// RENDERERS --------------------------- // RENDERERS ---------------------------
.createTable('renderers', table => { .createTable('renderers', table => {
table.increments('id').primary() table.string('key').notNullable().primary()
table.string('key').notNullable().unique()
table.boolean('isEnabled').notNullable().defaultTo(false) table.boolean('isEnabled').notNullable().defaultTo(false)
table.json('config') table.json('config')
}) })
// SEARCH ------------------------------ // SEARCH ------------------------------
.createTable('searchEngines', table => { .createTable('searchEngines', table => {
table.increments('id').primary() table.string('key').notNullable().primary()
table.string('key').notNullable().unique()
table.boolean('isEnabled').notNullable().defaultTo(false) table.boolean('isEnabled').notNullable().defaultTo(false)
table.json('config') table.json('config')
}) })
// SETTINGS ---------------------------- // SETTINGS ----------------------------
.createTable('settings', table => { .createTable('settings', table => {
table.increments('id').primary() table.string('key').notNullable().primary()
table.string('key').notNullable().unique()
table.json('value') table.json('value')
table.string('updatedAt').notNullable() table.string('updatedAt').notNullable()
}) })
// STORAGE ----------------------------- // STORAGE -----------------------------
.createTable('storage', table => { .createTable('storage', table => {
table.increments('id').primary() table.string('key').notNullable().primary()
table.string('key').notNullable().unique()
table.boolean('isEnabled').notNullable().defaultTo(false) table.boolean('isEnabled').notNullable().defaultTo(false)
table.string('mode', ['sync', 'push', 'pull']).notNullable().defaultTo('push') table.string('mode', ['sync', 'push', 'pull']).notNullable().defaultTo('push')
table.json('config') table.json('config')
......
...@@ -8,7 +8,8 @@ const path = require('path') ...@@ -8,7 +8,8 @@ const path = require('path')
/* global WIKI */ /* global WIKI */
const dbTypes = { const dbTypes = {
mysql: 'MySQL / MariaDB', mysql: 'MySQL',
mariadb: 'MariaDB',
postgres: 'PostgreSQL', postgres: 'PostgreSQL',
sqlite: 'SQLite', sqlite: 'SQLite',
mssql: 'MS SQL Server' mssql: 'MS SQL Server'
...@@ -35,11 +36,33 @@ module.exports = { ...@@ -35,11 +36,33 @@ module.exports = {
dbType() { dbType() {
return _.get(dbTypes, WIKI.config.db.type, 'Unknown DB') return _.get(dbTypes, WIKI.config.db.type, 'Unknown DB')
}, },
dbVersion() { async dbVersion() {
return _.get(WIKI.models, 'knex.client.version', 'Unknown version') let version = 'Unknown Version'
switch (WIKI.config.db.type) {
case 'mariadb':
case 'mysql':
const resultMYSQL = await WIKI.models.knex.raw('SELECT VERSION() as version;')
version = _.get(resultMYSQL, '[0][0].version', 'Unknown Version')
break
case 'mssql':
const resultMSSQL = await WIKI.models.knex.raw('SELECT @@VERSION as version;')
version = _.get(resultMSSQL, '[0].version', 'Unknown Version')
break
case 'postgres':
version = _.get(WIKI.models, 'knex.client.version', 'Unknown Version')
break
case 'sqlite':
version = _.get(WIKI.models, 'knex.client.driver.VERSION', 'Unknown Version')
break
}
return version
}, },
dbHost() { dbHost() {
return WIKI.config.db.host if (WIKI.config.db.type === 'sqlite') {
return WIKI.config.db.storage
} else {
return WIKI.config.db.host
}
}, },
latestVersion() { latestVersion() {
return '2.0.0' // TODO return '2.0.0' // TODO
......
...@@ -12,6 +12,7 @@ const commonHelper = require('../helpers/common') ...@@ -12,6 +12,7 @@ const commonHelper = require('../helpers/common')
*/ */
module.exports = class Authentication extends Model { module.exports = class Authentication extends Model {
static get tableName() { return 'authentication' } static get tableName() { return 'authentication' }
static get idColumn() { return 'key' }
static get jsonSchema () { static get jsonSchema () {
return { return {
...@@ -19,7 +20,6 @@ module.exports = class Authentication extends Model { ...@@ -19,7 +20,6 @@ module.exports = class Authentication extends Model {
required: ['key', 'isEnabled'], required: ['key', 'isEnabled'],
properties: { properties: {
id: {type: 'integer'},
key: {type: 'string'}, key: {type: 'string'},
isEnabled: {type: 'boolean'}, isEnabled: {type: 'boolean'},
config: {type: 'object'}, config: {type: 'object'},
......
...@@ -12,6 +12,7 @@ const commonHelper = require('../helpers/common') ...@@ -12,6 +12,7 @@ const commonHelper = require('../helpers/common')
*/ */
module.exports = class Editor extends Model { module.exports = class Editor extends Model {
static get tableName() { return 'editors' } static get tableName() { return 'editors' }
static get idColumn() { return 'key' }
static get jsonSchema () { static get jsonSchema () {
return { return {
...@@ -19,7 +20,6 @@ module.exports = class Editor extends Model { ...@@ -19,7 +20,6 @@ module.exports = class Editor extends Model {
required: ['key', 'isEnabled'], required: ['key', 'isEnabled'],
properties: { properties: {
id: {type: 'integer'},
key: {type: 'string'}, key: {type: 'string'},
isEnabled: {type: 'boolean'}, isEnabled: {type: 'boolean'},
config: {type: 'object'} config: {type: 'object'}
......
...@@ -5,6 +5,7 @@ const Model = require('objection').Model ...@@ -5,6 +5,7 @@ const Model = require('objection').Model
*/ */
module.exports = class User extends Model { module.exports = class User extends Model {
static get tableName() { return 'locales' } static get tableName() { return 'locales' }
static get idColumn() { return 'code' }
static get jsonSchema () { static get jsonSchema () {
return { return {
...@@ -12,7 +13,6 @@ module.exports = class User extends Model { ...@@ -12,7 +13,6 @@ module.exports = class User extends Model {
required: ['code', 'name'], required: ['code', 'name'],
properties: { properties: {
id: {type: 'integer'},
code: {type: 'string'}, code: {type: 'string'},
strings: {type: 'object'}, strings: {type: 'object'},
isRTL: {type: 'boolean', default: false}, isRTL: {type: 'boolean', default: false},
......
...@@ -12,6 +12,7 @@ const commonHelper = require('../helpers/common') ...@@ -12,6 +12,7 @@ const commonHelper = require('../helpers/common')
*/ */
module.exports = class Logger extends Model { module.exports = class Logger extends Model {
static get tableName() { return 'loggers' } static get tableName() { return 'loggers' }
static get idColumn() { return 'key' }
static get jsonSchema () { static get jsonSchema () {
return { return {
...@@ -19,7 +20,6 @@ module.exports = class Logger extends Model { ...@@ -19,7 +20,6 @@ module.exports = class Logger extends Model {
required: ['key', 'isEnabled'], required: ['key', 'isEnabled'],
properties: { properties: {
id: {type: 'integer'},
key: {type: 'string'}, key: {type: 'string'},
isEnabled: {type: 'boolean'}, isEnabled: {type: 'boolean'},
level: {type: 'string'}, level: {type: 'string'},
......
...@@ -12,6 +12,7 @@ const commonHelper = require('../helpers/common') ...@@ -12,6 +12,7 @@ const commonHelper = require('../helpers/common')
*/ */
module.exports = class Renderer extends Model { module.exports = class Renderer extends Model {
static get tableName() { return 'renderers' } static get tableName() { return 'renderers' }
static get idColumn() { return 'key' }
static get jsonSchema () { static get jsonSchema () {
return { return {
...@@ -19,7 +20,6 @@ module.exports = class Renderer extends Model { ...@@ -19,7 +20,6 @@ module.exports = class Renderer extends Model {
required: ['key', 'isEnabled'], required: ['key', 'isEnabled'],
properties: { properties: {
id: {type: 'integer'},
key: {type: 'string'}, key: {type: 'string'},
isEnabled: {type: 'boolean'}, isEnabled: {type: 'boolean'},
config: {type: 'object'} config: {type: 'object'}
......
...@@ -12,6 +12,7 @@ const commonHelper = require('../helpers/common') ...@@ -12,6 +12,7 @@ const commonHelper = require('../helpers/common')
*/ */
module.exports = class SearchEngine extends Model { module.exports = class SearchEngine extends Model {
static get tableName() { return 'searchEngines' } static get tableName() { return 'searchEngines' }
static get idColumn() { return 'key' }
static get jsonSchema () { static get jsonSchema () {
return { return {
...@@ -19,7 +20,6 @@ module.exports = class SearchEngine extends Model { ...@@ -19,7 +20,6 @@ module.exports = class SearchEngine extends Model {
required: ['key', 'isEnabled'], required: ['key', 'isEnabled'],
properties: { properties: {
id: {type: 'integer'},
key: {type: 'string'}, key: {type: 'string'},
isEnabled: {type: 'boolean'}, isEnabled: {type: 'boolean'},
level: {type: 'string'}, level: {type: 'string'},
......
...@@ -8,6 +8,7 @@ const _ = require('lodash') ...@@ -8,6 +8,7 @@ const _ = require('lodash')
*/ */
module.exports = class Setting extends Model { module.exports = class Setting extends Model {
static get tableName() { return 'settings' } static get tableName() { return 'settings' }
static get idColumn() { return 'key' }
static get jsonSchema () { static get jsonSchema () {
return { return {
...@@ -15,7 +16,6 @@ module.exports = class Setting extends Model { ...@@ -15,7 +16,6 @@ module.exports = class Setting extends Model {
required: ['key', 'value'], required: ['key', 'value'],
properties: { properties: {
id: {type: 'integer'},
key: {type: 'string'}, key: {type: 'string'},
value: {type: 'object'}, value: {type: 'object'},
createdAt: {type: 'string'}, createdAt: {type: 'string'},
......
...@@ -12,6 +12,7 @@ const commonHelper = require('../helpers/common') ...@@ -12,6 +12,7 @@ const commonHelper = require('../helpers/common')
*/ */
module.exports = class Storage extends Model { module.exports = class Storage extends Model {
static get tableName() { return 'storage' } static get tableName() { return 'storage' }
static get idColumn() { return 'key' }
static get jsonSchema () { static get jsonSchema () {
return { return {
...@@ -19,7 +20,6 @@ module.exports = class Storage extends Model { ...@@ -19,7 +20,6 @@ module.exports = class Storage extends Model {
required: ['key', 'isEnabled'], required: ['key', 'isEnabled'],
properties: { properties: {
id: {type: 'integer'},
key: {type: 'string'}, key: {type: 'string'},
isEnabled: {type: 'boolean'}, isEnabled: {type: 'boolean'},
mode: {type: 'string'}, mode: {type: 'string'},
......
This diff was suppressed by a .gitattributes entry.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment