diff --git a/database/src/main/resources/db/migration/V82__Add_Indexes_In_Dataset_Snapshot_Process.sql b/database/src/main/resources/db/migration/V82__Add_Indexes_In_Dataset_Snapshot_Process.sql
new file mode 100644
index 0000000000..d5064f681f
--- /dev/null
+++ b/database/src/main/resources/db/migration/V82__Add_Indexes_In_Dataset_Snapshot_Process.sql
@@ -0,0 +1,5 @@
+CREATE INDEX IF NOT EXISTS dataset_dataflowid_idx ON public.dataset (dataflowid);
+
+CREATE INDEX IF NOT EXISTS snapshot_reporting_dataset_id_idx ON public.snapshot (reporting_dataset_id);
+
+CREATE INDEX IF NOT EXISTS process_dataflow_dataset_status_idx ON public.process (dataflow_id, dataset_id, status);
\ No newline at end of file
diff --git a/frontend-service/src/conf/messages.en.json b/frontend-service/src/conf/messages.en.json
index 231eb3daff..4a609e2306 100644
--- a/frontend-service/src/conf/messages.en.json
+++ b/frontend-service/src/conf/messages.en.json
@@ -1595,6 +1595,8 @@
"tableDataByIdError": "The data of the table could not be loaded. Please try again or contact the Service Desk if the issue persists.",
"tableInfo": "Table info",
"tableIsNotCreated": "The table {:tableName} is not created in the design, please check it.
",
+ "tableLockedDueToData": "The table is locked because it has data. Delete the data first if you want to modify the schema.",
+ "tableLockedDueToDataAction": "This action is locked because the table has data. Delete the data first if you want to modify the schema.",
"tableRelationsTitle": "Note: By default, all reference field values must be found in the target field values",
"tables": "Tables",
"tablesAndFields": "Tables & Fields",
diff --git a/frontend-service/src/views/DatasetDesigner/_components/TabsDesigner/TabsDesigner.jsx b/frontend-service/src/views/DatasetDesigner/_components/TabsDesigner/TabsDesigner.jsx
index e2330afd8b..ea3c4a5557 100644
--- a/frontend-service/src/views/DatasetDesigner/_components/TabsDesigner/TabsDesigner.jsx
+++ b/frontend-service/src/views/DatasetDesigner/_components/TabsDesigner/TabsDesigner.jsx
@@ -85,6 +85,7 @@ export const TabsDesigner = ({
const [tabHasErrors, setTabHasErrors] = useState(false);
const [warningMessage, setWarningMessage] = useState();
const [warningMessageTitle, setWarningMessageTitle] = useState();
+ const [tableHasData, setTableHasData] = useState({});
useEffect(() => {
if (!isNil(datasetSchema) && !isEmpty(datasetSchema)) {
@@ -118,6 +119,16 @@ export const TabsDesigner = ({
}
}, [isWarningDialogVisible]);
+ useEffect(() => {
+ if (!isEmpty(tabs) && bigData) {
+ tabs.forEach(tab => {
+ if (!tab.addTab) {
+ checkTableHasData(tab.tableSchemaId);
+ }
+ });
+ }
+ }, [tabs]);
+
const onChangeFields = (fields, isLinkChange, tabSchemaId) => {
const inmTabs = [...tabs];
const tabIdx = TabsUtils.getIndexByTableProperty(tabSchemaId, inmTabs, 'tableSchemaId');
@@ -190,7 +201,11 @@ export const TabsDesigner = ({
if (bigData) {
checkTabs?.forEach(item => {
- if (!item?.dataAreManuallyEditable) length -= 1;
+ const isTableLocked = tableHasData[item.tableSchemaId] === true;
+
+ if (!item?.dataAreManuallyEditable || isTableLocked) {
+ length -= 1;
+ }
});
}
@@ -382,6 +397,26 @@ export const TabsDesigner = ({
}
};
+ const checkTableHasData = async tableSchemaId => {
+ try {
+ const response = await DatasetService.getTableDataDL({
+ datasetId: datasetId,
+ tableSchemaId: tableSchemaId,
+ pageNum: 0,
+ pageSize: 1,
+ levelError: ['CORRECT', 'INFO', 'WARNING', 'ERROR', 'BLOCKER']
+ });
+
+ const hasData = response?.records?.length > 0;
+ setTableHasData(prev => ({ ...prev, [tableSchemaId]: hasData }));
+
+ return hasData;
+ } catch (error) {
+ console.error('TabsDesigner - checkTableHasData.', error);
+ return false;
+ }
+ };
+
const errorDialogFooter = (