Files
e-tib.com/scripts/manual-schema-fix.ts
Marc Mintel 26d325df44
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 38s
Build & Deploy / 🧪 QA (push) Successful in 1m22s
Build & Deploy / 🏗️ Build (push) Successful in 4m27s
Build & Deploy / 🚀 Deploy (push) Failing after 39s
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 2s
fix(config): ensure analytics URL has protocol to prevent build crash
2026-05-12 13:01:18 +02: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();