Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[releases/24.0] Add TriggerMovedTableSchemaCheck #870

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ codeunit 329 "No. Series Installer"

trigger OnInstallAppPerCompany()
begin
TriggerMovedTableSchemaSanityCheck();
SetupNoSeriesImplementation();
end;

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

UpgradeTag.SetUpgradeTag(NoSeriesUpgradeTags.GetImplementationUpgradeTag());
end;

/// <summary>
/// This method is used to ensure that the runtime metadata matches the schema for moved tables.
/// </summary>
/// <remarks>
/// 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.
/// Should this code fail it would indicate a bug in the server code. The code is not expected to fail.
/// </remarks>
internal procedure TriggerMovedTableSchemaSanityCheck()
var
NoSeries: Record "No. Series";
NoSeriesLine: Record "No. Series Line";
NoSeriesRelationship: Record "No. Series Relationship";
NoSeriesTenant: Record "No. Series Tenant";
#if not CLEAN24
NoSeriesLineSales: Record "No. Series Line Sales";
NoSeriesLinePurchase: Record "No. Series Line Purchase";
#endif
UpgradeTag: Codeunit "Upgrade Tag";
NoSeriesUpgradeTags: Codeunit "No. Series Upgrade Tags";
begin
if UpgradeTag.HasUpgradeTag(NoSeriesUpgradeTags.GetMovedTableSchemaSanityCheckUpgradeTag()) then
exit;

#pragma warning disable AA0175
if NoSeries.FindFirst() then;
if NoSeriesLine.FindFirst() then;
if NoSeriesRelationship.FindFirst() then;
if NoSeriesTenant.FindFirst() then;
#if not CLEAN24
if NoSeriesLineSales.FindFirst() then;
if NoSeriesLinePurchase.FindFirst() then;
#endif
#pragma warning restore AA0175

UpgradeTag.SetUpgradeTag(NoSeriesUpgradeTags.GetMovedTableSchemaSanityCheckUpgradeTag());
end;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------

namespace Microsoft.Foundation.NoSeries;
codeunit 328 "No. Series Upgrade"
{
Access = Internal;
Subtype = Upgrade;
InherentEntitlements = X;
InherentPermissions = X;

trigger OnUpgradePerCompany()
var
NoSeriesInstaller: Codeunit "No. Series Installer";
begin
NoSeriesInstaller.TriggerMovedTableSchemaSanityCheck();
end;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ codeunit 332 "No. Series Upgrade Tags"
begin
exit('MS-471519-AddImplementationExtensibility-20231206 ');
end;

procedure GetMovedTableSchemaSanityCheckUpgradeTag(): Code[250]
begin
exit('MS-523755-AddMovedTableSchemaSanityCheck-20240402');
end;
}
Loading