summaryrefslogtreecommitdiff
path: root/admin
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-05-22 07:03:43 +0100
committerLester Caine <lester@lsces.co.uk>2026-05-22 07:03:43 +0100
commite22c4ac772181cd7caab88b349b1ab6ae0ca8eb4 (patch)
tree44140ae2a89c6d3e081bf3bd0d86c95436359a0d /admin
parentd5b95cfa5cd87bfc21366d7a06836650d6f34cc4 (diff)
downloadliberty-e22c4ac772181cd7caab88b349b1ab6ae0ca8eb4.tar.gz
liberty-e22c4ac772181cd7caab88b349b1ab6ae0ca8eb4.tar.bz2
liberty-e22c4ac772181cd7caab88b349b1ab6ae0ca8eb4.zip
Add liberty_xref package-agnostic cross-reference mechanism
New tables: liberty_xref_type (text PK, package, sort_order), liberty_xref_source (package column for direct equality filtering), liberty_xref (data rows keyed by content_id, works for any package). Sequence liberty_xref_seq and indices on content_id and package columns. LibertyXref and LibertyXrefType classes provide the full store/load/step mechanism. Contact and stock register their own source types against the shared tables. Upgrade script 5.0.1.php creates the tables on existing installs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'admin')
-rwxr-xr-xadmin/schema_inc.php40
-rw-r--r--admin/upgrades/5.0.1.php63
2 files changed, 103 insertions, 0 deletions
diff --git a/admin/schema_inc.php b/admin/schema_inc.php
index e2462d5..a77678f 100755
--- a/admin/schema_inc.php
+++ b/admin/schema_inc.php
@@ -218,6 +218,42 @@ $tables = [
, CONSTRAINT `lib_attachment_meta_title_ref` FOREIGN KEY (`meta_title_id`) REFERENCES `" . BIT_DB_PREFIX . "liberty_meta_titles` (`meta_title_id`) '
",
+ 'liberty_xref_type' => "
+ xref_type C(32) PRIMARY,
+ package C(20) NOTNULL,
+ title C(64),
+ sort_order I2,
+ role_id I4,
+ type_href C(256)
+",
+
+ 'liberty_xref_source' => "
+ source C(20) PRIMARY,
+ package C(20) NOTNULL,
+ xref_type C(32),
+ cross_ref_title C(64),
+ multi I2,
+ role_id I4,
+ cross_ref_href C(256),
+ template C(32),
+ data X
+",
+
+ 'liberty_xref' => "
+ xref_id I8 PRIMARY,
+ content_id I8 NOTNULL,
+ source C(20),
+ xorder I2,
+ xref I8,
+ xkey C(32),
+ xkey_ext C(250),
+ data X,
+ start_date T,
+ last_update_date T,
+ entry_date T,
+ end_date T
+",
+
];
global $gBitInstaller;
@@ -258,6 +294,9 @@ $indices = [
'lib_attachment_meta_idx' => [ 'table' => 'liberty_attachment_meta_data', 'cols' => 'attachment_id', 'opts' => null ],
'lib_attachment_meta_type_idx' => [ 'table' => 'liberty_attachment_meta_data', 'cols' => 'meta_type_id', 'opts' => null ],
'lib_attachment_meta_title_idx' => [ 'table' => 'liberty_attachment_meta_data', 'cols' => 'meta_title_id', 'opts' => null ],
+ 'liberty_xref_content_idx' => [ 'table' => 'liberty_xref', 'cols' => 'content_id', 'opts' => null ],
+ 'liberty_xref_source_pkg_idx' => [ 'table' => 'liberty_xref_source', 'cols' => 'package', 'opts' => null ],
+ 'liberty_xref_type_pkg_idx' => [ 'table' => 'liberty_xref_type', 'cols' => 'package', 'opts' => null ],
];
foreach( array_keys($constraints) AS $tableName ) {
@@ -280,6 +319,7 @@ $sequences = [
'liberty_structures_id_seq' => [ 'start' => 4 ],
'liberty_meta_types_id_seq' => [ 'start' => 1 ],
'liberty_meta_titles_id_seq' => [ 'start' => 1 ],
+ 'liberty_xref_seq' => [ 'start' => 1 ],
];
$gBitInstaller->registerSchemaSequences( LIBERTY_PKG_NAME, $sequences );
diff --git a/admin/upgrades/5.0.1.php b/admin/upgrades/5.0.1.php
new file mode 100644
index 0000000..f20d190
--- /dev/null
+++ b/admin/upgrades/5.0.1.php
@@ -0,0 +1,63 @@
+<?php
+/**
+ * @package liberty
+ */
+
+global $gBitInstaller;
+
+$gBitInstaller->registerPackageUpgrade(
+ [
+ 'package' => 'liberty',
+ 'version' => '5.0.1',
+ 'description' => 'Add liberty_xref tables: a package-agnostic cross-reference mechanism for attaching typed, multi-valued, date-tracked attributes to any liberty content.',
+ ],
+ [
+ [ 'DATADICT' => [
+ [ 'CREATE' => [
+ 'liberty_xref_type' => "
+ xref_type C(32) PRIMARY,
+ package C(20) NOTNULL,
+ title C(64),
+ sort_order I2,
+ role_id I4,
+ type_href C(256)
+ ",
+ 'liberty_xref_source' => "
+ source C(20) PRIMARY,
+ package C(20) NOTNULL,
+ xref_type C(32),
+ cross_ref_title C(64),
+ multi I2,
+ role_id I4,
+ cross_ref_href C(256),
+ template C(32),
+ data X
+ ",
+ 'liberty_xref' => "
+ xref_id I8 PRIMARY,
+ content_id I8 NOTNULL,
+ source C(20),
+ xorder I2,
+ xref I8,
+ xkey C(32),
+ xkey_ext C(250),
+ data X,
+ start_date T,
+ last_update_date T,
+ entry_date T,
+ end_date T
+ ",
+ ]],
+ [ 'CREATESEQUENCE' => [
+ [ 'liberty_xref_seq' ],
+ ]],
+ [ 'CREATEINDEX' => [
+ [
+ 'liberty_xref_content_idx' => [ 'liberty_xref', 'content_id', null ],
+ 'liberty_xref_source_pkg_idx' => [ 'liberty_xref_source', 'package', null ],
+ 'liberty_xref_type_pkg_idx' => [ 'liberty_xref_type', 'package', null ],
+ ],
+ ]],
+ ]],
+ ]
+);