DB migration. osagoContracts from null to empty array
This commit is contained in:
parent
9ea088e3f4
commit
70ba09e9b6
18
migration.js
18
migration.js
@ -1,8 +1,8 @@
|
||||
const MongoClient = require('mongodb').MongoClient;
|
||||
const dotenv = require('dotenv');
|
||||
const dotenvExpand = require('dotenv-expand');
|
||||
import { MongoClient } from 'mongodb';
|
||||
import { config } from 'dotenv';
|
||||
import dotenvExpand from 'dotenv-expand';
|
||||
|
||||
let dotenvConf = dotenv.config();
|
||||
let dotenvConf = config();
|
||||
dotenvExpand(dotenvConf);
|
||||
|
||||
async function addUpdatedDate() {
|
||||
@ -64,9 +64,17 @@ async function fixNullNotes() {
|
||||
}
|
||||
}
|
||||
|
||||
async function fixNullOsagoContracts() {
|
||||
let client = await MongoClient.connect(process.env.MONGO_CONNECTION_STRING);
|
||||
let db = client.db('autocatdev');
|
||||
let collection = db.collection('vehicles');
|
||||
await collection.updateMany({ osagoContracts: null }, { $set: { osagoContracts: [] } });
|
||||
}
|
||||
|
||||
(async () => {
|
||||
//await addUpdatedDate();
|
||||
//await addDebugInfoStatus();
|
||||
await fixNullNotes();
|
||||
//await fixNullNotes();
|
||||
await fixNullOsagoContracts();
|
||||
console.log('====== Done ======');
|
||||
})();
|
||||
|
||||
@ -65,6 +65,7 @@ class Vehicle {
|
||||
v.updatedDate = v.addedDate;
|
||||
v.events = [];
|
||||
v.notes = [];
|
||||
v.osagoContracts = [];
|
||||
v.debugInfo = { autocod: new DebugInfo() };
|
||||
|
||||
return v;
|
||||
@ -161,6 +162,7 @@ class Vehicle {
|
||||
v.updatedDate = v.addedDate;
|
||||
v.events = [];
|
||||
v.notes = [];
|
||||
v.osagoContracts = [];
|
||||
v.debugInfo = { vin01base: new DebugInfo() };
|
||||
|
||||
return v;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user