RAISE NOTICE 'migrate fns.T_LOAD_SETTINGS % %', currentDate, to_char(current_timestamp, 'HH24:MI:SS');

DECLARE LoadSettingsEntityID_IES int;

SELECT EntityID INTO LoadSettingsEntityID_IES
FROM vclib.T_ENTITIES
WHERE EntName = 'LOAD_SETTINGS' AND "Schema" = 'IES'
LIMIT 1;

DELETE FROM FNS.T_LOAD_SETTINGS;
INSERT INTO FNS.T_LOAD_SETTINGS(LoadSettingsID, Name, CreateData, type_)
SELECT LoadSettingsID, Name, CreateData, LoadSettingsEntityID_IES
FROM IES.T_LOAD_SETTINGS;

RAISE NOTICE 'migrate fns.T_VERIFICATION_PATTERN % %', currentDate, to_char(current_timestamp, 'HH24:MI:SS');

DELETE FROM FNS.T_VERIFICATION_PATTERN;

INSERT INTO FNS.T_VERIFICATION_PATTERN 
SELECT VerificationPatternID, Name, Descr, Version, IgnoreFileCount, "Procedure", IsBulk, IsAdditional
FROM IES.T_VERIFICATION_PATTERN;

RAISE NOTICE 'migrate fns.T_FILE_PATTERN % %', currentDate, to_char(current_timestamp, 'HH24:MI:SS');

DELETE FROM FNS.T_FILE_PATTERN;

INSERT INTO FNS.T_FILE_PATTERN 
SELECT FilePatternID, VerificationPattern, Pattern, XsdSchema, LoadSchema, "Procedure", Version, IsRequired
FROM IES.T_FILE_PATTERN;

RAISE NOTICE 'migrate fns.T_LOAD_SETTINGS_PATTERNS % %', currentDate, to_char(current_timestamp, 'HH24:MI:SS');

DELETE FROM FNS.T_LOAD_SETTINGS_PATTERNS;

INSERT INTO FNS.T_LOAD_SETTINGS_PATTERNS 
SELECT LoadSettingsPatternsID, LoadSettings, VerificationPattern
FROM IES.T_LOAD_SETTINGS_PATTERNS;