/**Begin D:\pdm\PDM_UPGRADE\pdm_new\RIM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_RIM_INVOICE_FILE' AND KSQL_COL_NAME ='FORIGINAL_FILENAME') 
 ALTER TABLE T_RIM_INVOICE_FILE ADD (FORIGINAL_FILENAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INV_OVERSEA') 
 CREATE TABLE T_RIM_INV_OVERSEA (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,  
FTENANT_NO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSERIAL_NO NVARCHAR(36) DEFAULT ' ' NOT NULL,
FAWS_SERIAL_NO NVARCHAR(36) DEFAULT ' ' NOT NULL,
FINVOICE_NO NVARCHAR(32) DEFAULT ' ' NOT NULL,
FINVOICE_DATE DATETIME,
FDUE_DATE DATETIME,
FTAX_ORG BIGINT DEFAULT 0 NOT NULL,
FORG_ID BIGINT DEFAULT 0 NOT NULL,
FINVOICE_TYPE BIGINT DEFAULT 0 NOT NULL,
FRESOURCE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FEXPENSE_STATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FORIGINAL_STATE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FACCOUNT_DATE DATETIME,
FDELETE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTOTAL_AMOUNT DECIMAL(23,2) DEFAULT 0 NOT NULL,
FCURRENCY_NAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_RIM_INVOICE_FILE_HIS') 
 CREATE TABLE T_RIM_INVOICE_FILE_HIS (
FID BIGINT DEFAULT 0 NOT NULL,
FSERIAL_NO NVARCHAR(36) DEFAULT ' ' NOT NULL,
FFILE_HASH NVARCHAR(100) DEFAULT ' ' NOT NULL,
FORIGINAL_TYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPDF_URL NVARCHAR(300) DEFAULT ' ' NOT NULL,
FOFD_URL NVARCHAR(300) DEFAULT ' ' NOT NULL,
FIMAGE_URL NVARCHAR(300) DEFAULT ' ' NOT NULL,
FSNAPSHOT_URL NVARCHAR(300) DEFAULT ' ' NOT NULL,
FICON_URL NVARCHAR(300) DEFAULT ' ' NOT NULL,
FROTATION_ANGLE INT DEFAULT 0 NOT NULL,
FREGION NVARCHAR(35) DEFAULT ' ' NOT NULL,
FPIXEL NVARCHAR(20) DEFAULT ' ' NOT NULL,
FTENANT_NO NVARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATE_TIME DATETIME,
FUPDATE_TIME DATETIME,
FORIGINAL_STATE NVARCHAR(2) DEFAULT ' ' NOT NULL,
FORIGINAL_FILENAME NVARCHAR(100) DEFAULT ' ' NOT NULL
);



/**End D:\pdm\PDM_UPGRADE\pdm_new\RIM_table.sql **/
