feat: add status field to themes collection and update migration scripts
- Added a new "status" field to the themes collection with options: draft, published, and rejected. - Updated the migration script to include the new field and its options. - Created a new ingestion migration script to ensure the "status" field includes "rejected" as an option if not already present. - Added multiple hot-update files for webpack to support the new changes in the frontend.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import 'dotenv/config'
|
||||
import PocketBase from 'pocketbase'
|
||||
|
||||
const POCKETBASE_URL = process.env['POCKETBASE_URL'] ?? ''
|
||||
const POCKETBASE_ADMIN_EMAIL = process.env['POCKETBASE_ADMIN_EMAIL'] ?? ''
|
||||
const POCKETBASE_ADMIN_PASSWORD = process.env['POCKETBASE_ADMIN_PASSWORD'] ?? ''
|
||||
|
||||
if (!POCKETBASE_URL || !POCKETBASE_ADMIN_EMAIL || !POCKETBASE_ADMIN_PASSWORD) {
|
||||
console.error('Missing env vars')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const pb = new PocketBase(POCKETBASE_URL)
|
||||
await pb.admins.authWithPassword(POCKETBASE_ADMIN_EMAIL, POCKETBASE_ADMIN_PASSWORD)
|
||||
|
||||
const col = await pb.collections.getFirstListItem('name="themes"')
|
||||
|
||||
// Find the status field and update its allowed values to include 'rejected'
|
||||
const schema = col.schema as Array<{ name: string; type: string; options: Record<string, unknown> }>
|
||||
const statusField = schema.find((f) => f.name === 'status')
|
||||
|
||||
if (!statusField) {
|
||||
console.error('status field not found on themes')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const currentValues = (statusField.options['values'] as string[]) ?? []
|
||||
if (currentValues.includes('rejected')) {
|
||||
console.log('themes.status already includes "rejected" — nothing to do')
|
||||
return
|
||||
}
|
||||
|
||||
statusField.options['values'] = [...currentValues, 'rejected']
|
||||
|
||||
await pb.collections.update(col.id, { schema })
|
||||
console.log('✓ themes.status updated to include "rejected"')
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
Reference in New Issue
Block a user