fix(migration): minor fixes and modifications to DB scripts
This commit is contained in:
parent
cdf7dac6a3
commit
58c4b22f0f
|
|
@ -116,8 +116,9 @@ const createManyNewExpenses = async (timesheet_id: number, old_expenses: OldExpe
|
||||||
mileage = old_expense.value!;
|
mileage = old_expense.value!;
|
||||||
amount = mileage * 0.72;
|
amount = mileage * 0.72;
|
||||||
}
|
}
|
||||||
if (mileage < 0) {
|
if (mileage < 0 || amount < 0) {
|
||||||
console.warn(`expense of value less than '0' found`)
|
console.warn(`expense of value less than '0' found`)
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (old_expense.date == null) {
|
if (old_expense.date == null) {
|
||||||
|
|
|
||||||
|
|
@ -22,13 +22,13 @@ type OldShifts = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const extractOldShifts = async () => {
|
export const extractOldShifts = async () => {
|
||||||
for (let id = 1; id <= 61; id++) {
|
// for (let id = 1; id <= 61; id++) {
|
||||||
console.log(`Start of shift migration ***************************************************************`);
|
console.log(`Start of shift migration ***************************************************************`);
|
||||||
const new_employee = await findOneNewEmployee(id);
|
const new_employee = await findOneNewEmployee(50);
|
||||||
console.log(`Employee ${id} found in new DB`);
|
console.log(`Employee ${50} found in new DB`);
|
||||||
|
|
||||||
const new_timesheets = await findManyNewTimesheets(new_employee.id);
|
const new_timesheets = await findManyNewTimesheets(new_employee.id);
|
||||||
console.log(`New Timesheets found for employee ${id}`);
|
console.log(`New Timesheets found for employee ${50}`);
|
||||||
for (const ts of new_timesheets) {
|
for (const ts of new_timesheets) {
|
||||||
console.log(`start_date = ${ts.start_date} timesheet_id = ${ts.id}`)
|
console.log(`start_date = ${ts.start_date} timesheet_id = ${ts.id}`)
|
||||||
|
|
||||||
|
|
@ -62,7 +62,7 @@ export const extractOldShifts = async () => {
|
||||||
});
|
});
|
||||||
await createManyNewShifts(new_timesheet.id, old_shifts);
|
await createManyNewShifts(new_timesheet.id, old_shifts);
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
await prisma_legacy.$disconnect();
|
await prisma_legacy.$disconnect();
|
||||||
await prisma.$disconnect();
|
await prisma.$disconnect();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { extractOldTimesheets } from "scripts/migrate-timesheets";
|
// import { extractOldTimesheets } from "scripts/migrate-timesheets";
|
||||||
import { extractOldExpenses } from "scripts/migrate-expenses";
|
// import { extractOldExpenses } from "scripts/migrate-expenses";
|
||||||
import { extractOldShifts } from "scripts/migrate-shifts";
|
// import { extractOldShifts } from "scripts/migrate-shifts";
|
||||||
import { Injectable } from "@nestjs/common";
|
import { Injectable } from "@nestjs/common";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
|
@ -8,14 +8,14 @@ export class MigrationService {
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
async migrateTimesheets() {
|
async migrateTimesheets() {
|
||||||
extractOldTimesheets();
|
// extractOldTimesheets();
|
||||||
};
|
};
|
||||||
|
|
||||||
async migrateShifts() {
|
async migrateShifts() {
|
||||||
extractOldShifts();
|
// extractOldShifts();
|
||||||
}
|
}
|
||||||
|
|
||||||
async migrateExpenses() {
|
async migrateExpenses() {
|
||||||
extractOldExpenses();
|
// extractOldExpenses();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -18,7 +18,6 @@ import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
||||||
import { writeFileSync } from 'fs';
|
import { writeFileSync } from 'fs';
|
||||||
import * as session from 'express-session';
|
import * as session from 'express-session';
|
||||||
import * as passport from 'passport';
|
import * as passport from 'passport';
|
||||||
// import { extractOldTimesheets } from 'scripts/migrate-timesheets';
|
|
||||||
import { extractOldShifts } from 'scripts/migrate-shifts';
|
import { extractOldShifts } from 'scripts/migrate-shifts';
|
||||||
import { extractOldTimesheets } from 'scripts/migrate-timesheets';
|
import { extractOldTimesheets } from 'scripts/migrate-timesheets';
|
||||||
import { extractOldExpenses } from 'scripts/migrate-expenses';
|
import { extractOldExpenses } from 'scripts/migrate-expenses';
|
||||||
|
|
@ -98,6 +97,6 @@ async function bootstrap() {
|
||||||
// migration function calls
|
// migration function calls
|
||||||
// await extractOldTimesheets();
|
// await extractOldTimesheets();
|
||||||
// await extractOldShifts();
|
// await extractOldShifts();
|
||||||
// await extractOldExpenses();
|
await extractOldExpenses();
|
||||||
}
|
}
|
||||||
bootstrap();
|
bootstrap();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user