From abd7a1ca2e058854e6335b54f4119f009961a5ab Mon Sep 17 00:00:00 2001 From: Pitu Date: Thu, 25 Mar 2021 00:09:33 +0900 Subject: [PATCH] chore: move database migration script --- docs/migrating.md | 2 +- src/api/{ => scripts}/databaseMigration.js | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) rename src/api/{ => scripts}/databaseMigration.js (95%) diff --git a/docs/migrating.md b/docs/migrating.md index bc656e7..062b027 100644 --- a/docs/migrating.md +++ b/docs/migrating.md @@ -6,7 +6,7 @@ For starters we recommend cloning the new version somewhere else instead of `git - Then copy your `database/db` file from your v3 folder to the root of your v4 folder. - Make sure to install the dependencies by running `npm i` - You then need to run `npm run setup` from the v4 folder and finish the setup process. -- Once that's done you need to manually run `node src/api/databaseMigration.js` from the root folder of v4. +- Once that's done you need to manually run `node src/api/scripts/databaseMigration.js` from the root folder of v4. - This will migrate the v3 database to v4 and regenerate every single thumbnail in webp to save bandwidth. - After the migration finishes, the last step is to update your nginx config with the [newly provided script](./nginx.md). - Restart nginx with `sudo nginx -s reload`. diff --git a/src/api/databaseMigration.js b/src/api/scripts/databaseMigration.js similarity index 95% rename from src/api/databaseMigration.js rename to src/api/scripts/databaseMigration.js index 1e3518e..8fab0ac 100644 --- a/src/api/databaseMigration.js +++ b/src/api/scripts/databaseMigration.js @@ -3,7 +3,7 @@ require('dotenv').config(); const nodePath = require('path'); const moment = require('moment'); const jetpack = require('fs-jetpack'); -const ThumbUtil = require('./utils/ThumbUtil'); +const ThumbUtil = require('../utils/ThumbUtil'); const oldDb = require('knex')({ client: 'sqlite3', @@ -19,12 +19,7 @@ const newDb = require('knex')({ filename: nodePath.join(__dirname, '../../database/', 'database.sqlite') }, postProcessResponse: result => { - const booleanFields = [ - 'enabled', - 'enableDownload', - 'isAdmin', - 'nsfw' - ]; + const booleanFields = ['enabled', 'enableDownload', 'isAdmin', 'nsfw', 'generateZips', 'publicMode', 'userAccounts']; const processResponse = row => { Object.keys(row).forEach(key => {