v0.10.6 auto update tenants (seed)

This commit is contained in:
2026-03-20 21:07:19 -04:00
parent 3990471275
commit 66fd4c5377
4 changed files with 11 additions and 3 deletions

View File

@@ -273,6 +273,9 @@ router.post('/tenants/:slug/migrate', async (req, res) => {
const tenant = await queryOne('public', 'SELECT * FROM tenants WHERE slug=$1', [req.params.slug]);
if (!tenant) return res.status(404).json({ error: 'Tenant not found' });
await runMigrations(tenant.schema_name);
await seedSettings(tenant.schema_name);
await seedEventTypes(tenant.schema_name);
await seedUserGroups(tenant.schema_name);
const applied = await query(tenant.schema_name, 'SELECT * FROM schema_migrations ORDER BY version');
res.json({ success: true, migrations: applied });
} catch (e) { res.status(500).json({ error: e.message }); }
@@ -287,6 +290,11 @@ router.post('/migrate-all', async (req, res) => {
for (const t of tenants) {
try {
await runMigrations(t.schema_name);
// Also re-run seeding so new defaults (e.g. user groups, event types)
// are applied to existing tenants that were provisioned before they existed.
await seedSettings(t.schema_name);
await seedEventTypes(t.schema_name);
await seedUserGroups(t.schema_name);
results.push({ slug: t.slug, status: 'ok' });
} catch (e) {
results.push({ slug: t.slug, status: 'error', error: e.message });