Skip to content

Commit f35ad97

Browse files
authored
Add TriggerMovedTableSchemaCheck (#855)
<!-- Thank you for submitting a Pull Request. If you're new to contributing to BCApps please read our pull request guideline below * https://github.com/microsoft/BCApps/Contributing.md --> #### Summary <!-- Provide a general summary of your changes --> Adds TriggerMovedTableSchemaCheck #### Work Item(s) <!-- Add the issue number here after the #. The issue needs to be open and approved. Submitting PRs with no linked issues or unapproved issues is highly discouraged. --> Fixes [AB#523755](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/523755)
1 parent 85fb216 commit f35ad97

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

src/Business Foundation/App/NoSeries/src/Upgrade/NoSeriesInstaller.Codeunit.al

+38
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ codeunit 329 "No. Series Installer"
1515

1616
trigger OnInstallAppPerCompany()
1717
begin
18+
TriggerMovedTableSchemaSanityCheck();
1819
SetupNoSeriesImplementation();
1920
end;
2021

@@ -34,4 +35,41 @@ codeunit 329 "No. Series Installer"
3435

3536
UpgradeTag.SetUpgradeTag(NoSeriesUpgradeTags.GetImplementationUpgradeTag());
3637
end;
38+
39+
/// <summary>
40+
/// This method is used to ensure that the runtime metadata matches the schema for moved tables.
41+
/// </summary>
42+
/// <remarks>
43+
/// The if .. then statements ensure the code does not fail when the tables are empty. The presence of data is not important, the FindFirst will trigger a schema check.
44+
/// Should this code fail it would indicate a bug in the server code. The code is not expected to fail.
45+
/// </remarks>
46+
internal procedure TriggerMovedTableSchemaSanityCheck()
47+
var
48+
NoSeries: Record "No. Series";
49+
NoSeriesLine: Record "No. Series Line";
50+
NoSeriesRelationship: Record "No. Series Relationship";
51+
NoSeriesTenant: Record "No. Series Tenant";
52+
#if not CLEAN24
53+
NoSeriesLineSales: Record "No. Series Line Sales";
54+
NoSeriesLinePurchase: Record "No. Series Line Purchase";
55+
#endif
56+
UpgradeTag: Codeunit "Upgrade Tag";
57+
NoSeriesUpgradeTags: Codeunit "No. Series Upgrade Tags";
58+
begin
59+
if UpgradeTag.HasUpgradeTag(NoSeriesUpgradeTags.GetMovedTableSchemaSanityCheckUpgradeTag()) then
60+
exit;
61+
62+
#pragma warning disable AA0175
63+
if NoSeries.FindFirst() then;
64+
if NoSeriesLine.FindFirst() then;
65+
if NoSeriesRelationship.FindFirst() then;
66+
if NoSeriesTenant.FindFirst() then;
67+
#if not CLEAN24
68+
if NoSeriesLineSales.FindFirst() then;
69+
if NoSeriesLinePurchase.FindFirst() then;
70+
#endif
71+
#pragma warning restore AA0175
72+
73+
UpgradeTag.SetUpgradeTag(NoSeriesUpgradeTags.GetMovedTableSchemaSanityCheckUpgradeTag());
74+
end;
3775
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// ------------------------------------------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
// Licensed under the MIT License. See License.txt in the project root for license information.
4+
// ------------------------------------------------------------------------------------------------
5+
6+
namespace Microsoft.Foundation.NoSeries;
7+
codeunit 328 "No. Series Upgrade"
8+
{
9+
Access = Internal;
10+
Subtype = Upgrade;
11+
InherentEntitlements = X;
12+
InherentPermissions = X;
13+
14+
trigger OnUpgradePerCompany()
15+
var
16+
NoSeriesInstaller: Codeunit "No. Series Installer";
17+
begin
18+
NoSeriesInstaller.TriggerMovedTableSchemaSanityCheck();
19+
end;
20+
}

src/Business Foundation/App/NoSeries/src/Upgrade/NoSeriesUpgradeTags.Codeunit.al

+5
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,9 @@ codeunit 332 "No. Series Upgrade Tags"
1515
begin
1616
exit('MS-471519-AddImplementationExtensibility-20231206 ');
1717
end;
18+
19+
procedure GetMovedTableSchemaSanityCheckUpgradeTag(): Code[250]
20+
begin
21+
exit('MS-523755-AddMovedTableSchemaSanityCheck-20240402');
22+
end;
1823
}

0 commit comments

Comments
 (0)