mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-23 13:26:42 +02:00
style: auto-format codebase with Prettier
Applied formatting to 1487+ files using pnpm format:write - TypeScript/JavaScript files - Svelte components - Astro pages - JSON configs - Markdown docs 13 files still need manual review (Astro JSX comments)
This commit is contained in:
parent
0241f5554c
commit
d36b321d9d
3952 changed files with 661498 additions and 739751 deletions
|
|
@ -14,59 +14,58 @@ 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'
|
||||
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
|
||||
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);
|
||||
|
|
@ -74,4 +73,4 @@ async function migrate() {
|
|||
}
|
||||
|
||||
// Run migration
|
||||
migrate();
|
||||
migrate();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue