fix: correct NocoDB column creation endpoint and add startup delay
All checks were successful
Deploy HiHala Dashboard / deploy (push) Successful in 9s
All checks were successful
Deploy HiHala Dashboard / deploy (push) Successful in 9s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -34,6 +34,8 @@ app.listen(server.port, () => {
|
||||
console.log(' NocoDB: configured');
|
||||
console.log(' POST /api/etl/sync?mode=full|incremental');
|
||||
// Ensure Users table has permission fields
|
||||
// Delay slightly to ensure NocoDB is fully ready before migrating
|
||||
setTimeout(() => {
|
||||
discoverTableIds().then(tables => {
|
||||
if (tables['Users']) {
|
||||
return ensureTableFields(tables['Users'], [
|
||||
@@ -42,6 +44,7 @@ app.listen(server.port, () => {
|
||||
]);
|
||||
}
|
||||
}).catch(err => console.warn(' NocoDB migration warning:', err.message));
|
||||
}, 3000);
|
||||
} else {
|
||||
console.log(' NocoDB: WARNING — not configured');
|
||||
}
|
||||
|
||||
@@ -126,13 +126,14 @@ export async function fetchAllRecords<T>(tableId: string): Promise<T[]> {
|
||||
}
|
||||
|
||||
export async function ensureTableFields(tableId: string, fields: Array<{ title: string; uidt: string }>): Promise<void> {
|
||||
const json = await fetchJson(
|
||||
`${nocodb.url}/api/v2/tables/${tableId}/fields`
|
||||
) as { list: Array<{ title: string }> };
|
||||
const existing = new Set(json.list.map(f => f.title));
|
||||
// GET /api/v2/meta/tables/{id} returns table with columns array
|
||||
const table = await fetchJson(
|
||||
`${nocodb.url}/api/v2/meta/tables/${tableId}`
|
||||
) as { columns: Array<{ title: string }> };
|
||||
const existing = new Set((table.columns || []).map(f => f.title));
|
||||
for (const field of fields) {
|
||||
if (!existing.has(field.title)) {
|
||||
await fetchJson(`${nocodb.url}/api/v2/tables/${tableId}/fields`, {
|
||||
await fetchJson(`${nocodb.url}/api/v2/meta/tables/${tableId}/columns`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(field),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user