Manually adding links in the Postgres database

Hi Douglas,

That forum post you’ve linked to was from nearly 10 years ago and I’d actually just meant it to be illustrating a problem I was having with the indexes applied to the table at the time. I would strongly encourage you to avoid adding links manually as there’s a complex relationship between tables that isn’t fully constrained by DB code.

Normally we’d encourage clients to use the JS API:
https://matrix.squiz.net/manuals/web-services/chapters/javascript-api#linking

If PHP is more your style:

$GLOBALS['SQ_SYSTEM']->setRunLevel(SQ_RUN_LEVEL_FORCED);
$linkid = $GLOBALS['SQ_SYSTEM']->am->createAssetLink(
    $majorAsset,
    $minorAsset,
    $linkType
);
$GLOBALS['SQ_SYSTEM']->restoreRunLevel();

but there’s a lot less sanity checking on calls to the PHP API (especially with the run level downgraded) so it’s safe to say this isn’t supported.