From b2f292cc39fee54be0cc248594a5287aab8796e6 Mon Sep 17 00:00:00 2001 From: NGPixel Date: Sun, 5 Jul 2020 15:59:02 -0400 Subject: [PATCH] fix: MSSQL migration 2.5.1 --- .eslintrc.yml | 1 - client/components/history.vue | 2 +- dev/cypress/ci-setup.sh | 3 +-- server/db/migrations/2.5.1.js | 21 +++++++++++++++++++++ 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 0a3e42ea..56f0f735 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -13,4 +13,3 @@ globals: document: false navigator: false window: false - FuseBox: false diff --git a/client/components/history.vue b/client/components/history.vue index d4475766..0fb8fbd3 100644 --- a/client/components/history.vue +++ b/client/components/history.vue @@ -322,7 +322,7 @@ export default { this.target = this.cache[0] if (this.effectivePermissions) { - this.$store.set('page/effectivePermissions',JSON.parse(Buffer.from(this.effectivePermissions, 'base64').toString())) + this.$store.set('page/effectivePermissions', JSON.parse(Buffer.from(this.effectivePermissions, 'base64').toString())) } }, methods: { diff --git a/dev/cypress/ci-setup.sh b/dev/cypress/ci-setup.sh index 7d03a014..6381a728 100644 --- a/dev/cypress/ci-setup.sh +++ b/dev/cypress/ci-setup.sh @@ -20,8 +20,7 @@ mssql) sleep 30 docker exec db /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "Password123!" -Q 'CREATE DATABASE wiki' docker run -d -p 3000:3000 --name wiki --network="host" -e "DB_TYPE=mssql" -e "DB_HOST=localhost" -e "DB_PORT=1433" -e "DB_NAME=wiki" -e "DB_USER=SA" -e "DB_PASS=Password123!" requarks/wiki:canary-$BUILD_BUILDNUMBER - docker logs wiki - sleep 15 + sleep 5 docker logs wiki ;; sqlite) diff --git a/server/db/migrations/2.5.1.js b/server/db/migrations/2.5.1.js index 8cf75a6c..3666b1bf 100644 --- a/server/db/migrations/2.5.1.js +++ b/server/db/migrations/2.5.1.js @@ -1,6 +1,27 @@ +/* global WIKI */ + exports.up = async knex => { await knex('authentication').where('isEnabled', false).del() + // -> Knex bug #3855 workaround + // -> https://github.com/knex/knex/pull/3855 + if (WIKI.config.db.type === 'mssql') { + await knex.schema.raw(` + DECLARE @constraint varchar(100) = (SELECT default_constraints.name + FROM sys.all_columns + INNER JOIN sys.tables + ON all_columns.object_id = tables.object_id + INNER JOIN sys.schemas + ON tables.schema_id = schemas.schema_id + INNER JOIN sys.default_constraints + ON all_columns.default_object_id = default_constraints.object_id + WHERE schemas.name = 'dbo' + AND tables.name = 'authentication' + AND all_columns.name = 'isEnabled') + + IF @constraint IS NOT NULL EXEC('ALTER TABLE authentication DROP CONSTRAINT ' + @constraint)`) + } + await knex.schema .alterTable('authentication', table => { table.dropColumn('isEnabled')