mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-17 21:25:54 +02:00
feat: create duplicate template functionality feat: add support of csv and xlsx for bulk contacts import feat: add info text for forms and dashboard button feat: implement functionality to delete a PDF page while editing the document feat: show completed documents in which signers included but not owner in completed reports feat: add delete folder button in opensign drive feat: introduce Bcc email support for sending completed documents feat: allow merging multiple pdf while drafting document and template feat: add 'My Initials' tab for auto-signing in request-sign flow feat: add support for redirect URL to navigate after document completion feat: introduce privacy policy and digital signature terms before signing documents. feat: add feature to allow adding new pages to existing document feat: add save signature, initials, stamp functionality in sign pad for logged in user feat: add preferences menu feat: add save custom email template, notifyonsignature, set timezone, allow signature types in preferences feat: secure local url feat: implement Italian language translation feat: implement German language translation feat: update menu name from report to documents and shift contactbook in main menu feat: provide edit contact functionality fix: unable to delete folder when all its documents are deleted fix: fields.push is not function fix: document loading issue in opensign drive fix: adjust the guest signature flow to display the document in full screen, eliminating any blank space which is displayed below the place holder in mobile view fix: resolve issue of instance of pdfdict or pdfstream but got undefined build(deps): update dependencies refactor: change note text from add contact form
72 lines
2.4 KiB
JavaScript
72 lines
2.4 KiB
JavaScript
import dotenv from 'dotenv';
|
|
import { MongoClient } from 'mongodb';
|
|
import { generateId } from '../Utils.js';
|
|
dotenv.config();
|
|
|
|
export default async function createContactIndex() {
|
|
// Provide the complete MongoDB connection URL with the database name
|
|
const uri = process.env.MONGODB_URI || 'mongodb://localhost:27017/dev'; // Replace with your MongoDB URI
|
|
const client = new MongoClient(uri);
|
|
try {
|
|
await client.connect();
|
|
const database = client.db();
|
|
|
|
const migrationCollection = database.collection('Migrationdb');
|
|
const migrationName = 'contactIndex_1';
|
|
|
|
// Check if the migration has already been executed
|
|
const migrationExists = await migrationCollection.findOne({ name: migrationName });
|
|
|
|
if (migrationExists) {
|
|
console.log(' INFO No migrations were executed, database schema was already up to date.');
|
|
console.log(' SUCCESS Successfully ran indexed migrations directly on db.');
|
|
return;
|
|
}
|
|
|
|
const collection = database.collection('contracts_Contactbook');
|
|
|
|
// Create the unique index, but only on documents where IsImported is true
|
|
const query = {
|
|
IsImported: { $eq: true },
|
|
$or: [{ IsDeleted: false }, { IsDeleted: { $eq: false } }],
|
|
}; // Include documents with IsImported: true and IsDeleted not true
|
|
await collection.createIndex(
|
|
{ _p_CreatedBy: 1, Email: 1, IsImported: 1 },
|
|
{ unique: true, partialFilterExpression: query }
|
|
);
|
|
|
|
// Save the migration record in the migrationdb collection
|
|
await migrationCollection.insertOne({
|
|
_id: generateId(10),
|
|
name: migrationName,
|
|
_created_at: new Date(),
|
|
_updated_at: new Date(),
|
|
executedAt: new Date(),
|
|
details: 'Created unique index on CreatedBy, IsImported, Email',
|
|
});
|
|
|
|
const migrationdb = database.collection('_SCHEMA');
|
|
// create migrationdb SCHEM migrationdb
|
|
|
|
// Document to be inserted
|
|
const schemaDocument = {
|
|
_id: 'Migrationdb',
|
|
objectId: 'string',
|
|
name: 'string',
|
|
updatedAt: 'date',
|
|
createdAt: 'date',
|
|
executedAt: 'date',
|
|
details: 'string',
|
|
};
|
|
|
|
// Insert the document
|
|
await migrationdb.insertOne(schemaDocument);
|
|
console.log(' Unique index created successfully.');
|
|
console.log(' SUCCESS Successfully ran indexed migrations directly on db.');
|
|
} catch (error) {
|
|
console.log(' ERROR running indexed migration:', error);
|
|
} finally {
|
|
await client.close();
|
|
}
|
|
}
|