mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-15 13:21:08 +02:00
- Add uload project with apps/web structure
- Reorganize from flat to monorepo structure
- Remove PocketBase binary and local data
- Update to pnpm and @uload/web namespace
- Add picture project to monorepo
- Remove embedded git repository
- Unify all package names to @{project}/{app} schema:
- @maerchenzauber/* (was @storyteller/*)
- @manacore/* (was manacore-*, manacore)
- @manadeck/* (was web, backend, manadeck)
- @memoro/* (was memoro-web, landing, memoro)
- @picture/* (already unified)
- @uload/web
- Add convenient dev scripts for all apps:
- pnpm dev:{project}:web
- pnpm dev:{project}:landing
- pnpm dev:{project}:mobile
- pnpm dev:{project}:backend
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
77 lines
No EOL
2.2 KiB
JavaScript
77 lines
No EOL
2.2 KiB
JavaScript
#!/usr/bin/env node
|
||
|
||
// Migration script to convert use_username links to username-prefixed short_codes
|
||
// This script:
|
||
// 1. Finds all links with use_username=true
|
||
// 2. Updates their short_code to include the username prefix
|
||
// 3. Removes the use_username field (done via PocketBase admin)
|
||
|
||
import PocketBase from 'pocketbase';
|
||
|
||
const pb = new PocketBase('http://localhost:8090');
|
||
|
||
async function migrate() {
|
||
try {
|
||
// Authenticate as admin (update with your credentials)
|
||
await pb.admins.authWithPassword('admin@example.com', 'your-password');
|
||
|
||
console.log('Fetching all links with use_username=true...');
|
||
|
||
// Get all links with use_username=true
|
||
const links = await pb.collection('links').getFullList({
|
||
filter: 'use_username = true',
|
||
expand: 'user_id'
|
||
});
|
||
|
||
console.log(`Found ${links.length} links to migrate`);
|
||
|
||
let successCount = 0;
|
||
let errorCount = 0;
|
||
|
||
for (const link of links) {
|
||
try {
|
||
// Get the username from the expanded user
|
||
const username = link.expand?.user_id?.username;
|
||
|
||
if (!username) {
|
||
console.error(`No username found for link ${link.id} (user: ${link.user_id})`);
|
||
errorCount++;
|
||
continue;
|
||
}
|
||
|
||
// Create new short_code with username prefix
|
||
const newShortCode = `${username}/${link.short_code}`;
|
||
|
||
console.log(`Updating link ${link.id}: ${link.short_code} -> ${newShortCode}`);
|
||
|
||
// Update the link
|
||
await pb.collection('links').update(link.id, {
|
||
short_code: newShortCode
|
||
});
|
||
|
||
successCount++;
|
||
} catch (error) {
|
||
console.error(`Error migrating link ${link.id}:`, error);
|
||
errorCount++;
|
||
}
|
||
}
|
||
|
||
console.log('\nMigration complete!');
|
||
console.log(`✅ Successfully migrated: ${successCount} links`);
|
||
console.log(`❌ Errors: ${errorCount} links`);
|
||
|
||
if (successCount > 0) {
|
||
console.log('\n⚠️ Next steps:');
|
||
console.log('1. Remove the use_username field from the links collection in PocketBase admin');
|
||
console.log('2. Test that all migrated links still work');
|
||
console.log('3. Deploy the updated application code');
|
||
}
|
||
|
||
} catch (error) {
|
||
console.error('Migration failed:', error);
|
||
process.exit(1);
|
||
}
|
||
}
|
||
|
||
// Run migration
|
||
migrate(); |