Add entity customer numbers and scope APIs via selected company.

Entity gets an optional unique-per-company number with allocate/peek/isNumberFree helpers. Company-scoped store methods no longer take companyId and resolve google_auth.selected_company instead.
This commit is contained in:
seb
2026-08-07 04:29:35 +02:00
parent 1e89e19863
commit 70e0a9ddc4
78 changed files with 940 additions and 772 deletions

View File

@@ -251,46 +251,50 @@
<!-- entity -->
<g id="node5" class="node">
<title>entity</title>
<polygon fill="#bee3f8" stroke="none" points="719.05,-1061.4 719.05,-1089.8 888.95,-1089.8 888.95,-1061.4 719.05,-1061.4"/>
<polygon fill="none" stroke="#a0aec0" points="719.05,-1061.4 719.05,-1089.8 888.95,-1089.8 888.95,-1061.4 719.05,-1061.4"/>
<polygon fill="#bee3f8" stroke="none" points="721.05,-1083.8 721.05,-1087.8 762.53,-1087.8 762.53,-1083.8 721.05,-1083.8"/>
<polygon fill="#bee3f8" stroke="none" points="762.53,-1083.8 762.53,-1087.8 804,-1087.8 804,-1083.8 762.53,-1083.8"/>
<polygon fill="#bee3f8" stroke="none" points="804,-1083.8 804,-1087.8 845.47,-1087.8 845.47,-1083.8 804,-1083.8"/>
<polygon fill="#bee3f8" stroke="none" points="845.47,-1083.8 845.47,-1087.8 886.95,-1087.8 886.95,-1083.8 845.47,-1083.8"/>
<text xml:space="preserve" text-anchor="start" x="788" y="-1071" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00" fill="#1a365d">entity</text>
<polygon fill="#ebf8ff" stroke="none" points="719.05,-1034.6 719.05,-1061.4 888.95,-1061.4 888.95,-1034.6 719.05,-1034.6"/>
<polygon fill="none" stroke="#a0aec0" points="719.05,-1034.6 719.05,-1061.4 888.95,-1061.4 888.95,-1034.6 719.05,-1034.6"/>
<text xml:space="preserve" text-anchor="start" x="724.05" y="-1044.8" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="14.00" fill="#2d3748">id</text>
<text xml:space="preserve" text-anchor="start" x="854.45" y="-1046.3" font-family="Helvetica,sans-Serif" font-size="9.00" fill="#718096">INT </text>
<text xml:space="preserve" text-anchor="start" x="871.45" y="-1046.3" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="9.00" fill="#718096">PK</text>
<polygon fill="#ebf8ff" stroke="none" points="719.05,-1007.8 719.05,-1034.6 888.95,-1034.6 888.95,-1007.8 719.05,-1007.8"/>
<polygon fill="none" stroke="#a0aec0" points="719.05,-1007.8 719.05,-1034.6 888.95,-1034.6 888.95,-1007.8 719.05,-1007.8"/>
<text xml:space="preserve" text-anchor="start" x="724.05" y="-1018" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="14.00" fill="#2d3748">customergroup_id</text>
<text xml:space="preserve" text-anchor="start" x="854.95" y="-1019.5" font-family="Helvetica,sans-Serif" font-size="9.00" fill="#718096">INT </text>
<text xml:space="preserve" text-anchor="start" x="871.95" y="-1019.5" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="9.00" fill="#718096">FK</text>
<polygon fill="#ffffff" stroke="none" points="719.05,-981 719.05,-1007.8 888.95,-1007.8 888.95,-981 719.05,-981"/>
<polygon fill="none" stroke="#a0aec0" points="719.05,-981 719.05,-1007.8 888.95,-1007.8 888.95,-981 719.05,-981"/>
<text xml:space="preserve" text-anchor="start" x="724.05" y="-988.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#2d3748">first_name?</text>
<text xml:space="preserve" text-anchor="start" x="812.43" y="-990.8" font-family="Helvetica,sans-Serif" font-size="9.00" fill="#718096">NVARCHAR(255)</text>
<polygon fill="#f7fafc" stroke="none" points="719.05,-954.2 719.05,-981 888.95,-981 888.95,-954.2 719.05,-954.2"/>
<polygon fill="none" stroke="#a0aec0" points="719.05,-954.2 719.05,-981 888.95,-981 888.95,-954.2 719.05,-954.2"/>
<text xml:space="preserve" text-anchor="start" x="724.05" y="-962" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#2d3748">name</text>
<text xml:space="preserve" text-anchor="start" x="812.43" y="-964" font-family="Helvetica,sans-Serif" font-size="9.00" fill="#718096">NVARCHAR(255)</text>
<polygon fill="#ffffff" stroke="none" points="719.05,-927.4 719.05,-954.2 888.95,-954.2 888.95,-927.4 719.05,-927.4"/>
<polygon fill="none" stroke="#a0aec0" points="719.05,-927.4 719.05,-954.2 888.95,-954.2 888.95,-927.4 719.05,-927.4"/>
<text xml:space="preserve" text-anchor="start" x="724.05" y="-935.2" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#2d3748">created_at</text>
<text xml:space="preserve" text-anchor="start" x="833.44" y="-937.2" font-family="Helvetica,sans-Serif" font-size="9.00" fill="#718096">DATETIME2</text>
<polygon fill="#f7fafc" stroke="none" points="719.05,-900.6 719.05,-927.4 888.95,-927.4 888.95,-900.6 719.05,-900.6"/>
<polygon fill="none" stroke="#a0aec0" points="719.05,-900.6 719.05,-927.4 888.95,-927.4 888.95,-900.6 719.05,-900.6"/>
<text xml:space="preserve" text-anchor="start" x="724.05" y="-908.4" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#2d3748">updated_at</text>
<text xml:space="preserve" text-anchor="start" x="833.44" y="-910.4" font-family="Helvetica,sans-Serif" font-size="9.00" fill="#718096">DATETIME2</text>
<polygon fill="#bee3f8" stroke="none" points="719.05,-1074.8 719.05,-1103.2 888.95,-1103.2 888.95,-1074.8 719.05,-1074.8"/>
<polygon fill="none" stroke="#a0aec0" points="719.05,-1074.8 719.05,-1103.2 888.95,-1103.2 888.95,-1074.8 719.05,-1074.8"/>
<polygon fill="#bee3f8" stroke="none" points="721.05,-1097.2 721.05,-1101.2 762.53,-1101.2 762.53,-1097.2 721.05,-1097.2"/>
<polygon fill="#bee3f8" stroke="none" points="762.53,-1097.2 762.53,-1101.2 804,-1101.2 804,-1097.2 762.53,-1097.2"/>
<polygon fill="#bee3f8" stroke="none" points="804,-1097.2 804,-1101.2 845.47,-1101.2 845.47,-1097.2 804,-1097.2"/>
<polygon fill="#bee3f8" stroke="none" points="845.47,-1097.2 845.47,-1101.2 886.95,-1101.2 886.95,-1097.2 845.47,-1097.2"/>
<text xml:space="preserve" text-anchor="start" x="788" y="-1084.4" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="12.00" fill="#1a365d">entity</text>
<polygon fill="#ebf8ff" stroke="none" points="719.05,-1048 719.05,-1074.8 888.95,-1074.8 888.95,-1048 719.05,-1048"/>
<polygon fill="none" stroke="#a0aec0" points="719.05,-1048 719.05,-1074.8 888.95,-1074.8 888.95,-1048 719.05,-1048"/>
<text xml:space="preserve" text-anchor="start" x="724.05" y="-1058.2" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="14.00" fill="#2d3748">id</text>
<text xml:space="preserve" text-anchor="start" x="854.45" y="-1059.7" font-family="Helvetica,sans-Serif" font-size="9.00" fill="#718096">INT </text>
<text xml:space="preserve" text-anchor="start" x="871.45" y="-1059.7" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="9.00" fill="#718096">PK</text>
<polygon fill="#ebf8ff" stroke="none" points="719.05,-1021.2 719.05,-1048 888.95,-1048 888.95,-1021.2 719.05,-1021.2"/>
<polygon fill="none" stroke="#a0aec0" points="719.05,-1021.2 719.05,-1048 888.95,-1048 888.95,-1021.2 719.05,-1021.2"/>
<text xml:space="preserve" text-anchor="start" x="724.05" y="-1031.4" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="14.00" fill="#2d3748">customergroup_id</text>
<text xml:space="preserve" text-anchor="start" x="854.95" y="-1032.9" font-family="Helvetica,sans-Serif" font-size="9.00" fill="#718096">INT </text>
<text xml:space="preserve" text-anchor="start" x="871.95" y="-1032.9" font-family="Helvetica,sans-Serif" font-weight="bold" font-size="9.00" fill="#718096">FK</text>
<polygon fill="#ffffff" stroke="none" points="719.05,-994.4 719.05,-1021.2 888.95,-1021.2 888.95,-994.4 719.05,-994.4"/>
<polygon fill="none" stroke="#a0aec0" points="719.05,-994.4 719.05,-1021.2 888.95,-1021.2 888.95,-994.4 719.05,-994.4"/>
<text xml:space="preserve" text-anchor="start" x="724.05" y="-1002.2" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#2d3748">first_name?</text>
<text xml:space="preserve" text-anchor="start" x="812.43" y="-1004.2" font-family="Helvetica,sans-Serif" font-size="9.00" fill="#718096">NVARCHAR(255)</text>
<polygon fill="#f7fafc" stroke="none" points="719.05,-967.6 719.05,-994.4 888.95,-994.4 888.95,-967.6 719.05,-967.6"/>
<polygon fill="none" stroke="#a0aec0" points="719.05,-967.6 719.05,-994.4 888.95,-994.4 888.95,-967.6 719.05,-967.6"/>
<text xml:space="preserve" text-anchor="start" x="724.05" y="-975.4" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#2d3748">name</text>
<text xml:space="preserve" text-anchor="start" x="812.43" y="-977.4" font-family="Helvetica,sans-Serif" font-size="9.00" fill="#718096">NVARCHAR(255)</text>
<polygon fill="#ffffff" stroke="none" points="719.05,-940.8 719.05,-967.6 888.95,-967.6 888.95,-940.8 719.05,-940.8"/>
<polygon fill="none" stroke="#a0aec0" points="719.05,-940.8 719.05,-967.6 888.95,-967.6 888.95,-940.8 719.05,-940.8"/>
<text xml:space="preserve" text-anchor="start" x="724.05" y="-948.6" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#2d3748">number?</text>
<text xml:space="preserve" text-anchor="start" x="812.43" y="-950.6" font-family="Helvetica,sans-Serif" font-size="9.00" fill="#718096">NVARCHAR(100)</text>
<polygon fill="#f7fafc" stroke="none" points="719.05,-914 719.05,-940.8 888.95,-940.8 888.95,-914 719.05,-914"/>
<polygon fill="none" stroke="#a0aec0" points="719.05,-914 719.05,-940.8 888.95,-940.8 888.95,-914 719.05,-914"/>
<text xml:space="preserve" text-anchor="start" x="724.05" y="-921.8" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#2d3748">created_at</text>
<text xml:space="preserve" text-anchor="start" x="833.44" y="-923.8" font-family="Helvetica,sans-Serif" font-size="9.00" fill="#718096">DATETIME2</text>
<polygon fill="#ffffff" stroke="none" points="719.05,-887.2 719.05,-914 888.95,-914 888.95,-887.2 719.05,-887.2"/>
<polygon fill="none" stroke="#a0aec0" points="719.05,-887.2 719.05,-914 888.95,-914 888.95,-887.2 719.05,-887.2"/>
<text xml:space="preserve" text-anchor="start" x="724.05" y="-895" font-family="Helvetica,sans-Serif" font-size="14.00" fill="#2d3748">updated_at</text>
<text xml:space="preserve" text-anchor="start" x="833.44" y="-897" font-family="Helvetica,sans-Serif" font-size="9.00" fill="#718096">DATETIME2</text>
</g>
<!-- entityaddress&#45;&gt;entity -->
<g id="edge11" class="edge">
<title>entityaddress:sw&#45;&gt;entity:n</title>
<g id="a_edge11"><a xlink:title="FK_entityaddress_entity">
<path fill="none" stroke="#9c4221" stroke-width="1.4" d="M770.61,-1506.8C706.89,-1443.08 778.65,-1197.26 783.05,-1097.69"/>
<polygon fill="#9c4221" stroke="#9c4221" stroke-width="1.4" points="785.5,-1097.97 783.21,-1090.92 780.6,-1097.86 785.5,-1097.97"/>
<path fill="none" stroke="#9c4221" stroke-width="1.4" d="M770.61,-1506.8C708.99,-1445.18 778.63,-1207.66 783.05,-1111.09"/>
<polygon fill="#9c4221" stroke="#9c4221" stroke-width="1.4" points="785.49,-1111.38 783.21,-1104.32 780.59,-1111.26 785.49,-1111.38"/>
</a>
</g>
</g>
@@ -298,8 +302,8 @@
<g id="edge10" class="edge">
<title>entity:nw&#45;&gt;customergroup:n</title>
<g id="a_edge10"><a xlink:title="FK_entity_customergroup">
<path fill="none" stroke="#276749" stroke-width="1.4" d="M718.05,-1034.6C718.05,-1034.6 617.38,-746.73 598.9,-693.88"/>
<polygon fill="#276749" stroke="#276749" stroke-width="1.4" points="601.32,-693.4 596.7,-687.6 596.7,-695.02 601.32,-693.4"/>
<path fill="none" stroke="#276749" stroke-width="1.4" d="M718.05,-1048C718.05,-1048 617.38,-749.08 598.9,-694.2"/>
<polygon fill="#276749" stroke="#276749" stroke-width="1.4" points="601.23,-693.46 596.68,-687.61 596.59,-695.02 601.23,-693.46"/>
</a>
</g>
</g>
@@ -417,8 +421,8 @@
<g id="edge12" class="edge">
<title>entitycontact:se&#45;&gt;entity:n</title>
<g id="a_edge12"><a xlink:title="FK_entitycontact_entity">
<path fill="none" stroke="#0987a0" stroke-width="1.4" d="M1187.06,-1426.4C1213.58,-1399.87 1203.57,-1375.18 1186.06,-1342 1095.94,-1171.3 833.12,-1281.33 824.93,-1097.77"/>
<polygon fill="#0987a0" stroke="#0987a0" stroke-width="1.4" points="827.39,-1097.86 824.78,-1090.92 822.49,-1097.97 827.39,-1097.86"/>
<path fill="none" stroke="#0987a0" stroke-width="1.4" d="M1187.06,-1426.4C1213.58,-1399.87 1203.99,-1374.95 1186.06,-1342 1095.42,-1175.44 833.37,-1291.07 824.95,-1111.27"/>
<polygon fill="#0987a0" stroke="#0987a0" stroke-width="1.4" points="827.4,-1111.26 824.79,-1104.32 822.5,-1111.37 827.4,-1111.26"/>
</a>
</g>
</g>
@@ -614,8 +618,8 @@
<g id="edge13" class="edge">
<title>entityhistory:sw&#45;&gt;entity:n</title>
<g id="a_edge13"><a xlink:title="FK_entityhistory_entity">
<path fill="none" stroke="#553c9a" stroke-width="1.4" d="M1268.98,-1426.4C1215,-1372.42 1281.1,-1314.44 1228,-1259.6 1106.49,-1134.1 874.55,-1261.96 866.43,-1097.89"/>
<polygon fill="#553c9a" stroke="#553c9a" stroke-width="1.4" points="868.88,-1097.86 866.26,-1090.92 863.98,-1097.98 868.88,-1097.86"/>
<path fill="none" stroke="#553c9a" stroke-width="1.4" d="M1268.98,-1426.4C1215,-1372.42 1281.1,-1314.44 1228,-1259.6 1108.17,-1135.84 874.61,-1272.58 866.43,-1111.15"/>
<polygon fill="#553c9a" stroke="#553c9a" stroke-width="1.4" points="868.89,-1111.26 866.26,-1104.32 863.99,-1111.38 868.89,-1111.26"/>
</a>
</g>
</g>
@@ -1627,8 +1631,8 @@
<g id="edge47" class="edge">
<title>manifest:e&#45;&gt;entity:n</title>
<g id="a_edge47"><a xlink:title="FK_manifest_entity">
<path fill="none" stroke="#3182ce" stroke-width="1.4" d="M222.49,-644.8C370.25,-644.8 405.07,-704.07 515,-802.8 629.39,-905.53 576.16,-1014.04 711.05,-1087.8 719.11,-1092.21 730.21,-1097.31 736.63,-1096.04"/>
<polygon fill="#3182ce" stroke="#3182ce" stroke-width="1.4" points="738.5,-1097.65 740.56,-1090.53 734.51,-1094.81 738.5,-1097.65"/>
<path fill="none" stroke="#3182ce" stroke-width="1.4" d="M222.49,-644.8C370.25,-644.8 406.12,-702.91 515,-802.8 631.93,-910.08 572.64,-1023.59 711.05,-1101.2 719.06,-1105.69 730.18,-1110.77 736.62,-1109.47"/>
<polygon fill="#3182ce" stroke="#3182ce" stroke-width="1.4" points="738.5,-1111.05 740.56,-1103.93 734.51,-1108.21 738.5,-1111.05"/>
</a>
</g>
</g>

Before

Width:  |  Height:  |  Size: 186 KiB

After

Width:  |  Height:  |  Size: 187 KiB