chore(backend): Disable mongo export script for now
This commit is contained in:
parent
2951f50ac8
commit
2c16f634a9
1 changed files with 34 additions and 31 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
/*
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import { PrismaClient } from '@prisma/client'
|
import { PrismaClient } from '@prisma/client'
|
||||||
|
@ -7,15 +8,15 @@ import { verifyConfig } from '../src/config.mjs'
|
||||||
|
|
||||||
const config = verifyConfig()
|
const config = verifyConfig()
|
||||||
|
|
||||||
/*
|
//
|
||||||
* Note: This is not intended to work for you
|
// Note: This is not intended to work for you
|
||||||
*
|
//
|
||||||
* This script imports a raw database dump of the current (v2)
|
// This script imports a raw database dump of the current (v2)
|
||||||
* FreeSewing backend and writes it to JSON.
|
// FreeSewing backend and writes it to JSON.
|
||||||
*
|
//
|
||||||
* This is not the kind of thing you should try to run yourself
|
// This is not the kind of thing you should try to run yourself
|
||||||
* because for one thing you do not have a raw database dump
|
// because for one thing you do not have a raw database dump
|
||||||
*/
|
//
|
||||||
|
|
||||||
// Dumped data folder
|
// Dumped data folder
|
||||||
const dir = '/home/joost/'
|
const dir = '/home/joost/'
|
||||||
|
@ -26,10 +27,10 @@ const file = 'freesewing-dump.json'
|
||||||
data = filterData(JSON.parse(fs.readFileSync(path.resolve(dir, file), { encoding: 'utf-8' })))
|
data = filterData(JSON.parse(fs.readFileSync(path.resolve(dir, file), { encoding: 'utf-8' })))
|
||||||
console.log(JSON.stringify(data, null, 2))
|
console.log(JSON.stringify(data, null, 2))
|
||||||
|
|
||||||
/*
|
//
|
||||||
* Only migrate user data if the user was active in the last 12 months
|
// Only migrate user data if the user was active in the last 12 months
|
||||||
* Unless they are patrons. Keep patrons regardless coz patrons rock.
|
// Unless they are patrons. Keep patrons regardless coz patrons rock.
|
||||||
*/
|
//
|
||||||
function filterData(data) {
|
function filterData(data) {
|
||||||
let i = 0
|
let i = 0
|
||||||
const filtered = {
|
const filtered = {
|
||||||
|
@ -65,18 +66,18 @@ function filterData(data) {
|
||||||
return filtered
|
return filtered
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
//
|
||||||
* Migrates role field
|
// Migrates role field
|
||||||
*/
|
//
|
||||||
function getRole(entry) {
|
function getRole(entry) {
|
||||||
if (entry.handle === 'joost') return 'admin'
|
if (entry.handle === 'joost') return 'admin'
|
||||||
if (entry.patron > 0) return 'patron'
|
if (entry.patron > 0) return 'patron'
|
||||||
return 'user'
|
return 'user'
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
//
|
||||||
* Migrates consent field
|
// Migrates consent field
|
||||||
*/
|
//
|
||||||
function getConsent(entry) {
|
function getConsent(entry) {
|
||||||
let consent = 0
|
let consent = 0
|
||||||
if (entry.consent.profile) consent++
|
if (entry.consent.profile) consent++
|
||||||
|
@ -85,9 +86,9 @@ function getConsent(entry) {
|
||||||
return consent
|
return consent
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
//
|
||||||
* Migrates user entry
|
// Migrates user entry
|
||||||
*/
|
//
|
||||||
function migrateUser(entry) {
|
function migrateUser(entry) {
|
||||||
const now = Date.now()
|
const now = Date.now()
|
||||||
const lastLogin = new Date(entry.time?.login || 0)
|
const lastLogin = new Date(entry.time?.login || 0)
|
||||||
|
@ -120,9 +121,9 @@ function migrateUser(entry) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
//
|
||||||
* Migrates person entry
|
// Migrates person entry
|
||||||
*/
|
//
|
||||||
function migratePerson(entry) {
|
function migratePerson(entry) {
|
||||||
return {
|
return {
|
||||||
user: entry.user,
|
user: entry.user,
|
||||||
|
@ -137,9 +138,9 @@ function migratePerson(entry) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
//
|
||||||
* Migrates pattern entry
|
// Migrates pattern entry
|
||||||
*/
|
//
|
||||||
function migratePattern(entry) {
|
function migratePattern(entry) {
|
||||||
return {
|
return {
|
||||||
handle: entry.handle,
|
handle: entry.handle,
|
||||||
|
@ -152,12 +153,14 @@ function migratePattern(entry) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
//
|
||||||
* Migrates subscriber entry
|
// Migrates subscriber entry
|
||||||
*/
|
//
|
||||||
function migrateSubscriber(entry) {
|
function migrateSubscriber(entry) {
|
||||||
return {
|
return {
|
||||||
createdAt: entry.created,
|
createdAt: entry.created,
|
||||||
email: entry.email,
|
email: entry.email,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue