/* * Copyright 2025 John G Stroh * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Sync Metadata Model * Tracks cross-environment data synchronization state */ const mongoose = require('mongoose'); const syncMetadataSchema = new mongoose.Schema({ // Sync type identifier type: { type: String, required: true, unique: true, enum: ['prod_audit', 'prod_blog', 'prod_documents'] }, // Last successful sync timestamp last_sync_time: { type: Date, required: true }, // Source environment source_environment: { type: String, required: true, enum: ['production', 'staging'] }, // Sync statistics stats: { total_synced: { type: Number, default: 0 }, last_batch_size: { type: Number, default: 0 }, last_batch_duration_ms: { type: Number, default: 0 }, errors_count: { type: Number, default: 0 } }, // Last sync result last_result: { success: Boolean, error_message: String, synced_count: Number, timestamp: Date } }, { timestamps: true }); module.exports = mongoose.model('SyncMetadata', syncMetadataSchema);