Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions lib/Service/Configuration/ImportHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2744,6 +2744,47 @@ private function autoCreateRegisterIfApplication(
$configuration->setRegisters($configRegisterIds);
$this->configurationMapper->update($configuration);
}

// EAGER MAGIC-TABLE CREATION (fixes #1615): provision the per-schema
// magic table for EVERY imported schema, not just those that ship
// seed data. Without this, log-style schemas (call_log, job_log,
// synchronization_log, …) — which typically have no seed data —
// never get their `oc_openregister_table_{registerId}_{schemaId}`
// table created on `occ app:enable`, and the first runtime write
// from a service like CallService throws "relation does not exist".
//
// Idempotent on re-import: ensureTableForRegisterSchema short-
// circuits when the table already exists (see MagicTableHandler
// line 109-112). The seed-objects loop further down still calls
// the same method as a defensive no-op.
if ($this->magicMapper !== null && $register !== null) {
foreach ($schemas as $schema) {
if ($schema instanceof Schema === false) {
continue;
}

try {
$this->magicMapper->ensureTableForRegisterSchema(
register: $register,
schema: $schema
);
} catch (\Exception $e) {
// Non-fatal: surfaced via logger so the rest of the
// import (other schemas, seed data) still completes.
$this->logger->warning(
message: '[ImportHandler] Failed to pre-create magic mapper table for schema during register auto-create',
context: [
'file' => __FILE__,
'line' => __LINE__,
'schema_id' => $schema->getId(),
'schema_slug' => $schema->getSlug(),
'register_id' => $register->getId(),
'error' => $e->getMessage(),
]
);
}
}
}
}//end autoCreateRegisterIfApplication()

/**
Expand Down
Loading