Skip to content

Commit

Permalink
Transmogrify plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Nov 7, 2025
1 parent a9158c3 commit 7b81dd1
Show file tree
Hide file tree
Showing 25 changed files with 4,258 additions and 1,569 deletions.
6 changes: 4 additions & 2 deletions app/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"PipelineToolkit\\": "availableplugins/PipelineToolkit/src/",
"SqlConnector\\": "availableplugins/SqlConnector/src/",
"SshKeyAuthenticator\\": "plugins/SshKeyAuthenticator/src/",
"CoreJob\\": "plugins/CoreJob/src/"
"CoreJob\\": "plugins/CoreJob/src/",
"Transmogrify\\": "plugins/Transmogrify/src/"
}
},
"autoload-dev": {
Expand All @@ -66,7 +67,8 @@
"PipelineToolkit\\Test\\": "availableplugins/PipelineToolkit/tests/",
"SqlConnector\\Test\\": "availableplugins/SqlConnector/tests/",
"SshKeyAuthenticator\\Test\\": "plugins/SshKeyAuthenticator/tests/",
"CoreJob\\Test\\": "plugins/CoreJob/tests/"
"CoreJob\\Test\\": "plugins/CoreJob/tests/",
"Transmogrify\\": "plugins/Transmogrify/src/"
}
},
"scripts": {
Expand Down
125 changes: 125 additions & 0 deletions app/plugins/Transmogrify/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Transmogrify (COmanage Registry Plugin)

Transmogrify is a command‑line migration tool bundled as a CakePHP plugin for COmanage Registry PE. It copies and transforms data from a legacy/source Registry schema (cm_… tables) into the PE target schema using a configurable mapping (config/schema/tables.json) plus code hooks for special cases.

It is designed to be:
- Safe by default: target tables that already contain data are skipped and not overwritten.
- Transparent: shows a progress bar with in‑line warnings and errors.
- Configurable: table selection, custom tables.json path, and optional helper modes (info, schema, etc).


## Prerequisites
- Configure database connections in local/config/database.php
- Source DB (used by Transmogrify) and target DB must both be reachable. Transmogrify initializes two Doctrine DBAL connections internally.
- The default tables mapping file is at:
- app/plugins/Transmogrify/config/schema/tables.json


## Command
Invoke from your app root:

- bin/cake transmogrify [options]

Cake’s standard flags also apply (eg: --verbose, --quiet, -h).


## Options
These options come directly from TransmogrifyCommand::buildOptionParser.

- --tables-config PATH
- Path to the transmogrify tables JSON config (defaults to the plugin’s tables.json).

- --dump-tables-config
- Print the effective tables configuration (after schema extension) and exit.

- --table NAME (repeatable)
- Migrate only the specified table(s). Repeat --table to select multiple.
- If omitted, Transmogrify processes all known tables in the configured order.

- --list-tables
- List available target tables from the transmogrify config and exit.

- --info
- Print source/target database configuration and exit.

- --info-json
- Output info in JSON (use with --info).

- --info-ping
- Ping connections and include connectivity + server version details (use with --info or --info-schema).

- --info-schema
- Print schema information and whether the database is empty (defaults to inspecting the target DB).

- --info-schema-role ROLE
- When used with --info-schema, select which database to inspect: source or target (default: target).

- --login-identifier-copy
- Enable helper logic to copy/set up login identifiers during migration (see your deployment’s identifier policy). Use together with --login-identifier-type to choose the identifier type.

- --login-identifier-type TYPE
- Identifier type value to use for login identifiers when --login-identifier-copy is set.


## Typical usage

- Migrate everything using the default mapping
- bin/cake transmogrify

- Preview environment information
- bin/cake transmogrify --info
- bin/cake transmogrify --info --info-json
- bin/cake transmogrify --info --info-ping

- Inspect schema state (target by default, or choose source)
- bin/cake transmogrify --info-schema
- bin/cake transmogrify --info-schema --info-schema-role source

- List the tables Transmogrify knows how to process
- bin/cake transmogrify --list-tables

- Dump the effective tables configuration
- bin/cake transmogrify --dump-tables-config

- Migrate a subset of tables (in safe order)
- bin/cake transmogrify --table types --table people --table person_roles

- Use a custom tables.json mapping
- bin/cake transmogrify --tables-config /path/to/your/tables.json

- Migrate with login identifier help
- bin/cake transmogrify --table identifiers --login-identifier-copy --login-identifier-type eppn

Hints:
- Combine Cake’s verbosity flags for extra diagnostics: add --verbose to see per‑row details emitted by some hooks; add --quiet to minimize output (progress still shows).


## Behavior notes
- Target table already has data? Transmogrify will skip that table and warn (no overwrite).
- Primary key sequences are aligned automatically to preserve/accept explicit IDs where possible.
- Ordering and foreign keys:
- The tool emits rows in a dependency‑friendly order and may retry deferred rows to satisfy FK dependencies.
- You’ll see warnings for rows skipped due to unresolved foreign keys or missing type mappings.
- Progress UI:
- A single‑line progress bar updates in place.
- Warnings and errors appear under the bar as they happen.


## Mapping and hooks
- Mapping is defined in config/schema/tables.json.
- You can specify per‑table field maps, boolean normalization, caches, and pre/post hooks.
- Some tables use custom SELECTs to ensure parent‑before‑child ordering (eg recursive chains).
- Type lookups depend on the ‘types’ cache; migrate ‘types’ early or include it in the same run if you migrate data that requires type IDs.


## Exit codes
- 0: Success
- Non‑zero: Error (check the emitted [ERROR] lines)


## Getting help
- bin/cake transmogrify -h
- Consult this plugin’s code for advanced behavior:
- src/Command/TransmogrifyCommand.php
- config/schema/tables.json
- src/Lib/Traits/* (type mapping, caching, row transformations, hooks)
7 changes: 7 additions & 0 deletions app/plugins/Transmogrify/config/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "Transmogrify",
"version": "1.0.0",
"description": "Data migration command to transmogrify data from a source database into the target schema.",
"types": {},
"schema": null
}
Loading

0 comments on commit 7b81dd1

Please sign in to comment.