chore: move database migration script

This commit is contained in:
Pitu 2021-03-25 00:09:33 +09:00
parent ab211c8a9e
commit abd7a1ca2e
2 changed files with 3 additions and 8 deletions

View File

@ -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`.

View File

@ -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 => {