-- Drop table

-- DROP TABLE public.t_eb_exportfilelist;

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_EXPORTFILELIST')

CREATE TABLE T_EB_EXPORTFILELIST (
	FID 				BIGINT                 	DEFAULT 0     	NOT NULL,
	FFILENAME 			NVARCHAR(500)    		DEFAULT ' ' 	NOT NULL,
	FMODEL 				BIGINT                 	DEFAULT 0     	NOT NULL,
	FURL 				NVARCHAR(2000)    		DEFAULT ' ' 	NOT NULL,
	FDOWNLOADCOUNT 		BIGINT                 	DEFAULT 0     	NOT NULL,
	FFILETYPE 			CHAR(1)    				DEFAULT ' ' 	NOT NULL,
	FSTATUS 			CHAR(1)    				DEFAULT ' ' 	NOT NULL,
	FCREATER 			BIGINT                 	DEFAULT 0     	NOT NULL,
	FCREATEDATE 		DATETIME,
	FMODIFIER 			BIGINT                 	DEFAULT 0     	NOT NULL,
	FMODIFYDATE 		DATETIME,
	FERRORMSG 			varchar(2000) 			DEFAULT ' '		NOT NULL
);
EXEC P_ALTERPK 'PK_EB_EXPORTFILELIST', 'T_EB_EXPORTFILELIST', 'FID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_EXPORTFILELIST')
CREATE INDEX IDX_EB_EXPORTFILELIST ON T_EB_EXPORTFILELIST (FMODEL ASC);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_EXPORTFILELIST_L')
CREATE TABLE T_EB_EXPORTFILELIST_L (
	FPKID 				NVARCHAR(36)  			NOT NULL,
	FID 				BIGINT 				 	DEFAULT 0		NOT NULL,
	FLOCALEID 			NVARCHAR(10) 			DEFAULT ' '		NOT NULL,
	FFILENAME 			NVARCHAR(500) 			DEFAULT ' '		NOT NULL
);
EXEC P_ALTERPK 'PK_EB_EXPORTFILELIST_L', 'T_EB_EXPORTFILELIST_L', 'FPKID', '1';
IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_EB_EXPORTFILELIST_L_0')
CREATE INDEX IDX_EB_EXPORTFILELIST_L_0 ON T_EB_EXPORTFILELIST_L (FPKID, FLOCALEID);
