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,14 +34,17 @@ app.listen(server.port, () => {
|
|||||||
console.log(' NocoDB: configured');
|
console.log(' NocoDB: configured');
|
||||||
console.log(' POST /api/etl/sync?mode=full|incremental');
|
console.log(' POST /api/etl/sync?mode=full|incremental');
|
||||||
// Ensure Users table has permission fields
|
// Ensure Users table has permission fields
|
||||||
discoverTableIds().then(tables => {
|
// Delay slightly to ensure NocoDB is fully ready before migrating
|
||||||
if (tables['Users']) {
|
setTimeout(() => {
|
||||||
return ensureTableFields(tables['Users'], [
|
discoverTableIds().then(tables => {
|
||||||
{ title: 'AllowedMuseums', uidt: 'LongText' },
|
if (tables['Users']) {
|
||||||
{ title: 'AllowedChannels', uidt: 'LongText' },
|
return ensureTableFields(tables['Users'], [
|
||||||
]);
|
{ title: 'AllowedMuseums', uidt: 'LongText' },
|
||||||
}
|
{ title: 'AllowedChannels', uidt: 'LongText' },
|
||||||
}).catch(err => console.warn(' NocoDB migration warning:', err.message));
|
]);
|
||||||
|
}
|
||||||
|
}).catch(err => console.warn(' NocoDB migration warning:', err.message));
|
||||||
|
}, 3000);
|
||||||
} else {
|
} else {
|
||||||
console.log(' NocoDB: WARNING — not configured');
|
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> {
|
export async function ensureTableFields(tableId: string, fields: Array<{ title: string; uidt: string }>): Promise<void> {
|
||||||
const json = await fetchJson(
|
// GET /api/v2/meta/tables/{id} returns table with columns array
|
||||||
`${nocodb.url}/api/v2/tables/${tableId}/fields`
|
const table = await fetchJson(
|
||||||
) as { list: Array<{ title: string }> };
|
`${nocodb.url}/api/v2/meta/tables/${tableId}`
|
||||||
const existing = new Set(json.list.map(f => f.title));
|
) as { columns: Array<{ title: string }> };
|
||||||
|
const existing = new Set((table.columns || []).map(f => f.title));
|
||||||
for (const field of fields) {
|
for (const field of fields) {
|
||||||
if (!existing.has(field.title)) {
|
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',
|
method: 'POST',
|
||||||
body: JSON.stringify(field),
|
body: JSON.stringify(field),
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user