Hi, Readers.
Last month I shared a new feature in Business Central 2021 wave 2 (BC19), Force sync of customer-specific extensions in online environments (ForceSync mode in Production Environment) I saw some questions after that, for example, if we keep the table no. and field No., will data be lost in Production Environment?
So in this post, I would like to briefly test some common scenarios, hope this will help.
Preparation
First, I prepared a new table and a new list page.
Table:
table 50100 "Lab Book"
{
Caption = 'Lab Book';
DataClassification = CustomerContent;
fields
{
field(1; "No."; Code[10])
{
Caption = 'No.';
DataClassification = CustomerContent;
}
field(2; Title; Text[30])
{
Caption = 'Title';
DataClassification = CustomerContent;
}
field(3; Author; Text[30])
{
Caption = 'Author';
DataClassification = CustomerContent;
}
field(4; Hardcover; Boolean)
{
Caption = 'Hardcover';
DataClassification = CustomerContent;
}
field(5; "Page Count"; Integer)
{
Caption = 'Page Count';
DataClassification = CustomerContent;
}
field(6; "Book Genres"; Option)
{
Caption = 'Book Genres';
OptionMembers = Classics,Fantasy,Horror,Comic;
}
}
keys
{
key(PK; "No.")
{
Clustered = true;
}
}
}
List page:
page 50101 "Lab Book List"
{
PageType = List;
UsageCategory = Lists;
ApplicationArea = All;
SourceTable = "Lab Book";
Caption = 'Book List';
layout
{
area(Content)
{
repeater(Group)
{
field("No."; Rec."No.")
{
ApplicationArea = All;
}
field(Title; Rec.Title)
{
ApplicationArea = All;
}
field(Author; Rec.Author)
{
ApplicationArea = All;
}
field(Hardcover; Rec.Hardcover)
{
ApplicationArea = All;
}
field("Page Count"; Rec."Page Count")
{
ApplicationArea = All;
}
field("Book Genres"; Rec."Book Genres")
{
ApplicationArea = All;
}
}
}
}
}
Then upload it to the production environment.


Add some test data.

Using Force Schema Sync Mode.


PS: If you use Add Schema Sync Mode, there will be an error when the table schema is changed in a destructive way in an extension. (I don’t know why this error is displayed in Japanese)

Deployment failed. Errors: App ID : 8ed41111-a4d2-4d39-ad0e-5f1200490e8f Message : { 次のエラーにより、NAV 拡張機能 ‘Test Force Sync mode by ZHU YUN 19.0.0.1’ をアップグレードできませんでした: ‘Table Lab Book :: テーブル ‘Lab Book’ が見つかりません。削除するテーブルが一時的なテーブルである場合か、別のアプリへの移行によって移動する場合を除き、テーブルの削除は許可されていません。’。 } – Job Id : c4305ca2-5b2d-4726-ba5d-84eef4d03251
Could not upgrade the NAV extension ‘Test Force Sync mode by ZHU YUN 19.0.0.1’ due to the following error: ‘Table Lab Book :: The table ‘Lab Book’ cannot be located. Removing tables is not allowed unless they are temporary or are being moved by migration to another app.’.

Change table name

The data will be preserved.

Change table ID

The data will be preserved.

PS: if you change the table ID, please don’t forget to generate a new permission set.
Package validation failed due to the following error(s): (1,13): error PTE0004: Table ‘50101’ is missing a matching permission set.
warning PTE0014: The XML file ‘/perm/file0_extensionsPermissionSet.xml’ should not contain Permissions or Permission Sets. Instead, use the dedicated AL object ‘PermissionSet’. – Job Id : 8255bfff-f36b-4208-ae55-a15291999ef9

Change both table name and table ID


The data will be lost.

Change field name
Rename fields including primary key.

The data will be preserved.

Change field ID

The data will be preserved.

Change both field name and field ID


The data will be lost.

Change field type
Text -> Code, Text -> Boolean

The data will be lost.

Change Option to Enum

The data will be preserved.

Change Primary Key

The data will be preserved. (please be careful that changing the primary key may cause many other problems)

Increase field length

The data will be preserved.

Reduce field length

If you reduce the length of a field by less than the length of the current data, then the data will be partially lost.

Delete fields

The data will be lost.

Note: If you delete a field contained in the Primary Key, the data will all be lost.


Delete tables
The data will be lost.

In summary
Action | Install | Data Loss |
Change table name | 〇 | ✖ |
Change table ID | 〇 | ✖ |
Change both table name and table ID | 〇 | 〇 |
Change field name | 〇 | ✖ |
Change field ID | 〇 | ✖ |
Change both field name and field ID | 〇 | 〇 |
Change field type | 〇 | 〇 |
Change Option to Enum | 〇 | ✖ |
Change Primary Key | 〇 | ✖ |
Increase field length | 〇 | ✖ |
Reduce field length | 〇 | △ |
Delete fields | 〇 | 〇 |
Delete tables | 〇 | 〇 |
END
Hope this will help.
Thanks for reading.
ZHU
コメント