Fix tests and add changelog
This commit is contained in:
34
keep-notes/scripts/fix-order.ts
Normal file
34
keep-notes/scripts/fix-order.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { PrismaClient } from '@prisma/client'
|
||||
|
||||
const prisma = new PrismaClient()
|
||||
|
||||
async function fixOrder() {
|
||||
try {
|
||||
// Get all notes sorted by creation date
|
||||
const notes = await prisma.note.findMany({
|
||||
orderBy: [
|
||||
{ isPinned: 'desc' },
|
||||
{ createdAt: 'asc' }
|
||||
]
|
||||
})
|
||||
|
||||
console.log(`Found ${notes.length} notes`)
|
||||
|
||||
// Update order values
|
||||
for (let i = 0; i < notes.length; i++) {
|
||||
await prisma.note.update({
|
||||
where: { id: notes[i].id },
|
||||
data: { order: i }
|
||||
})
|
||||
console.log(`Updated note ${notes[i].id} - order: ${i}`)
|
||||
}
|
||||
|
||||
console.log('✅ Order values fixed!')
|
||||
} catch (error) {
|
||||
console.error('Error:', error)
|
||||
} finally {
|
||||
await prisma.$disconnect()
|
||||
}
|
||||
}
|
||||
|
||||
fixOrder()
|
||||
Reference in New Issue
Block a user