fix: restore CMS connectivity and schema
- Exposed Directus port 8055 for local health checks and scripting - Added scripts to fix admin token and manually create missing collections - Verified all service health checks are passing
This commit is contained in:
68
scripts/manual-schema-fix.ts
Normal file
68
scripts/manual-schema-fix.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import client, { ensureAuthenticated } from '../lib/directus';
|
||||
import { createCollection, createField } from '@directus/sdk';
|
||||
|
||||
async function setupSchema() {
|
||||
console.log('🏗️ Manually creating contact_submissions collection...');
|
||||
|
||||
try {
|
||||
// 1. Authenticate (using token from config)
|
||||
await ensureAuthenticated();
|
||||
|
||||
// 2. Create collection
|
||||
console.log('📡 Creating "contact_submissions" collection...');
|
||||
await client.request(
|
||||
createCollection({
|
||||
collection: 'contact_submissions',
|
||||
meta: {
|
||||
icon: 'contact_mail',
|
||||
color: '#002b49',
|
||||
display_template: '{{name}} | {{email}}',
|
||||
},
|
||||
schema: {
|
||||
name: 'contact_submissions',
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
// 3. Create fields
|
||||
console.log('📡 Creating fields for "contact_submissions"...');
|
||||
|
||||
// name
|
||||
await client.request(
|
||||
createField('contact_submissions', {
|
||||
field: 'name',
|
||||
type: 'string',
|
||||
meta: { interface: 'input' },
|
||||
}),
|
||||
);
|
||||
|
||||
// email
|
||||
await client.request(
|
||||
createField('contact_submissions', {
|
||||
field: 'email',
|
||||
type: 'string',
|
||||
meta: { interface: 'input' },
|
||||
}),
|
||||
);
|
||||
|
||||
// message
|
||||
await client.request(
|
||||
createField('contact_submissions', {
|
||||
field: 'message',
|
||||
type: 'text',
|
||||
meta: { interface: 'textarea' },
|
||||
}),
|
||||
);
|
||||
|
||||
console.log('✨ Collection and fields created successfully!');
|
||||
} catch (error: any) {
|
||||
console.error('❌ Error creating schema:');
|
||||
if (error.errors) {
|
||||
console.error(JSON.stringify(error.errors, null, 2));
|
||||
} else {
|
||||
console.error(error.message || error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setupSchema();
|
||||
Reference in New Issue
Block a user