	----------------------------------------
	NETX DB upgrade processing and SQL-files
	----------------------------------------
	
	1. DB upgrade processing based on python script db_upgrade_process.py (installed into /opt/allot/bin dir)
	   and SQL-files deployed into /opt/allot/upgrade/DB directory. 
	    Usage - python db_upgrade_process.py <dest_version>
	    Example - python /opt/allot/bin/db_upgrade_process.py 15.2.10b07 
		 *** Since build 15.3.10b08 (02.2019) parameter <dest_version> not in use
		 
	   db_upgrade_process.py run  SQL-files in ascending order by name related from current version to destination version ,
	    SQL-files makes all required changes into NETX DB.
		
		** till build 15.3.10b08
	   Current version is getting from /opt/allot/products/sp.ver file 
	   Version paths(tree) between sp versions describe in file - /opt/allot/upgrade/DB/upgrade_paths.txt
	    Example - 
	      [15.1.60b02]
          NEXT_VERSION=15.1.60b03

         [15.1.60b03]
         NEXT_VERSION=15.2.10b01

         [15.2.10b01]
         NEXT_VERSION=15.2.10b02 
         
       Before each new build need update(add new section) to this file(/opt/allot/upgrade/DB/upgrade paths.txt) not depend exist DB changes or not!!!
         New section format 
            [Current version]
            NEXT_VERSION=<dest version> 
	    **
        
       *** Since build 15.3.10b08 (02.2019)
	   Instead of versions names for upgrade will be use DB upgrade marker(base) - will be change for each DB change not depended of version build
	    marker(base) name convention - <YEARMMDD>_<BASE_VERSION>. Example - 20190131_15310
	   Current version(db marker) is getting from DB - PUBLIC.PARAM table - NAME='Version', SUBNAME='db_upgrade_base' value from 'STR_VAL' column
        **After each DB change this value in PUBLIC.PARAM table should be changed accordingly 	   
       Destination version(db marker) is getting from /opt/allot/upgrade/DB/upgrade_info.txt file	   
		Example - DESTINATION_VERSION=20190223_15310	
		
	   After each DB change files /opt/allot/upgrade/DB/upgrade paths.txt and /opt/allot/upgrade/DB/upgrade_info.txt should be changed
	    Example of upgrade paths.txt -
		 [15.1.710b21]
         NEXT_VERSION=20190131_15310
		 
		 [20190131_15310]
         NEXT_VERSION=20190220_15310

         [20190220_15310]
         NEXT_VERSION=20190223_15310  
		  
	   
	2. DB changes should be wrapped by appropriate checks to prevent to make the same change twice and cause SQL errors
	   during upgrade processing. 
	   Should be used [CREATE OR REPLACE ..]; [IF NOT EXISTS ] SQL clauses or some SQL/plpgSQL code  
	   See some examples below
	   
	3. To guarantee SQL-files ascending order by name follows name convention should be use -
	      <YEARMMDD>_<VERSION>_<fileNUM>.sql ,
	      <VERSION> - XX_X[X]_XX[X]bXX (15_1_10b02)
	      <fileNUM> - XX (01,02,...11...99) - no more than 99 files for the same date/version
	   Examples - 20170214_15_1_10b02_02.sql; 20170215_15_1_410b01_01.sql  
	   
       *** Since build 15.3.10b08 (02.2019)
       	<YEARMMDD>_<BASE_VERSION>_<fileNUM>.sql  
        <YEARMMDD>_<BASE_VERSION> approppriate DB upgrade sign(base)		
	    Examples - 20190223_15310_01.sql; 20190223_15310_02.sql
		
	---------------------   
	SQL wrappers examples
	---------------------
	
	 Upgrade function(stored procedure)
	 ----------------------------------
	    CREATE OR REPLACE FUNCTION jobs_purge()
	     ...
	     
	 Add table (** from postgresql 9.2 use [IF NOT EXISTS ] clause**)
	 ----------------------
	 DO LANGUAGE plpgsql $$
		BEGIN
		PERFORM 1
		    FROM
		        pg_catalog.pg_class c
		        JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
		    WHERE
		        n.nspname = 'purge'
		        AND c.relname = 'param1'
		        AND c.relkind = 'r';
		        
		    IF NOT FOUND THEN
		      -- create table
		        create table purge.param1 (name varchar(20), subname varchar(20), int_val integer);
		    END IF;
		END;
	$$;  
	
	Insert default data to new/exist table
	--------------------------------------
	Use - COPY <table_name>(<col_name>, ...,<col_name>) from '/opt/allot/upgrade/DB/<table_name>_<VERSION>';
	Default delemiter is <TAB>;  NULL value - \N
	example - 
	  COPY param (name,subname,int_val,str_val,date_val,description) FROM '/opt/allot/upgrade/DB/param_15_1_10b03.dat';
	
	Add column to table (** from postgresql 9.2 use [IF NOT EXISTS ] clause**) 
    ----------------------------------
    DO
	$$
	BEGIN
		IF not EXISTS (SELECT column_name 
		               FROM information_schema.columns 
		               WHERE table_schema='purge' and table_name='param1' and column_name='str_val') THEN
		alter table purge.param1 add column str_val varchar(20) default null ;
		END IF;
	END
	$$   