Files
klz-cables.com/scripts/manual-schema-fix.ts
Marc Mintel 1f758758e3
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 13s
Build & Deploy / 🧪 QA (push) Successful in 1m43s
Build & Deploy / 🏗️ Build (push) Successful in 7m8s
Build & Deploy / 🚀 Deploy (push) Failing after 19s
Build & Deploy / 🧪 Smoke Test (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 2s
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
2026-02-17 16:20:03 +01:00

69 lines
1.7 KiB
TypeScript

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();