mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-18 13:09:40 +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
|
|
@ -11,64 +11,65 @@ async function migrate() {
|
|||
try {
|
||||
console.log('Starting migration...');
|
||||
console.log('This script will update links with use_username=true to use the new format');
|
||||
|
||||
|
||||
// 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;
|
||||
let skippedCount = 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;
|
||||
}
|
||||
|
||||
|
||||
// Check if already migrated (contains slash)
|
||||
if (link.short_code.includes('/')) {
|
||||
console.log(`Link ${link.id} already migrated: ${link.short_code}`);
|
||||
skippedCount++;
|
||||
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.message);
|
||||
errorCount++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
console.log('\n=== Migration Summary ===');
|
||||
console.log(`✅ Successfully migrated: ${successCount} links`);
|
||||
console.log(`⏭️ Skipped (already migrated): ${skippedCount} links`);
|
||||
console.log(`❌ Errors: ${errorCount} links`);
|
||||
|
||||
|
||||
if (successCount > 0) {
|
||||
console.log('\n⚠️ Important: The use_username field should be removed from the collection schema');
|
||||
console.log(
|
||||
'\n⚠️ Important: The use_username field should be removed from the collection schema'
|
||||
);
|
||||
console.log('You can do this manually in PocketBase Admin UI');
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('Migration failed:', error);
|
||||
process.exit(1);
|
||||
|
|
@ -76,4 +77,4 @@ async function migrate() {
|
|||
}
|
||||
|
||||
// Run migration
|
||||
migrate();
|
||||
migrate();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue