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

fix: mssql initial migration crash

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