godcrm/backend/scripts/ensure-system-tables-per-space.js
GOD CRM Release f89e074dd1
Some checks failed
CI / Lint / Typecheck / Test / Build (push) Has been cancelled
CI / PostgreSQL Integration Tests (push) Has been cancelled
GOD CRM — public scrubbed snapshot
Governed substrate for autonomous agents: scoped identity (passports),
audited actions, MCP workspace. Infra IPs and secrets redacted for public release.
2026-08-10 04:01:45 +03:00

29 lines
1,004 B
JavaScript

// Ensure per-space System Data tables (Projects, Tables, Files)
import { dbAll } from '../database/connection.js';
import { ensureCoreSystemTablesForSpace } from '../services/SystemTablesCreator.js';
async function main() {
const spaces = await dbAll('SELECT id, name FROM spaces ORDER BY id');
console.log(`Found ${spaces.length} spaces`);
for (const space of spaces) {
const result = await ensureCoreSystemTablesForSpace(space.id);
if (result) {
console.log(
`[space ${space.id} - ${space.name}] System Data project ${result.systemProjectId} | Projects ${result.projectsTableId} | Tables ${result.tablesTableId} | Files ${result.filesTableId}`
);
} else {
console.log(`[space ${space.id} - ${space.name}] skipped (no data)`);
}
}
}
main()
.then(() => {
console.log('Ensure system tables completed');
process.exit(0);
})
.catch((err) => {
console.error('Failed to ensure system tables per space:', err);
process.exit(1);
});