Restauração do código oficial do GPI-JWT-V3

This commit is contained in:
2026-03-18 21:55:33 +00:00
commit 405d121b0e
208 changed files with 38123 additions and 0 deletions

41
migrate_clerk_fields.cjs Normal file
View File

@@ -0,0 +1,41 @@
const mongoose = require('mongoose');
const uri = "mongodb+srv://admtracksteel:29OHAHpKTI8XcCNt@cluster0.a4xiilu.mongodb.net/ts_gpi?retryWrites=true&w=majority&appName=Cluster0";
async function migrateDB() {
try {
console.log('Connecting to MongoDB...');
await mongoose.connect(uri);
console.log('Connected.');
const db = mongoose.connection.db;
// 1. Rename clerkId to externalId in users
console.log('Migrating Users...');
await db.collection('users').updateMany(
{ clerkId: { $exists: true } },
{ $rename: { "clerkId": "externalId" } }
);
// 2. Rename clerkUserId to userId in organizationmembers
console.log('Migrating OrganizationMembers...');
await db.collection('organizationmembers').updateMany(
{ clerkUserId: { $exists: true } },
{ $rename: { "clerkUserId": "userId" } }
);
// 3. Rename clerkId to externalId in organizations
console.log('Migrating Organizations...');
await db.collection('organizations').updateMany(
{ clerkId: { $exists: true } },
{ $rename: { "clerkId": "externalId" } }
);
console.log('Migration completed successfully.');
await mongoose.disconnect();
} catch (err) {
console.error('Migration failed:', err);
process.exit(1);
}
}
migrateDB();