v0.10.6 auto update tenants (seed)
This commit is contained in:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user