-- Create Table Statement for 'Email'
DROP TABLE IF EXISTS `EMAIL`;
CREATE TABLE `EMAIL` (
	ID bigint(20) NOT NULL,
	TEMPLATE_CODE varchar,
	EXTERNAL_REFERENCE_CODE bigint(20),
	CREATE_DATE datetime,
	TO_EMAIL varchar,
	SUBJECT varchar,
	MESSAGE varchar,
	ATTACHMENT_CODE bigint(20),
	FILE_EXTENTION varchar,
	FIRST_NAME varchar,
	LAST_NAME varchar,
	CUSTOMER_ACCOUNT_CODE varchar,
	CUSTOMER_ACCOUNT_BALANCE int(11),
	MERCHANT_ACCOUNT_CODE int(11) NOT NULL,
	MERCHANT_NAME varchar,
	MERCHANT_ACCOUNT_NAME varchar,
	TRANSACTION_CODE varchar,
	TRANSACTION_AMOUNT int(11),
	TRANSACTION_BALANCE int(11),
	TRANSACTION_DATE datetime,
	TRANSACTION_DUE_DATE datetime,
	NOTE varchar,
	RESPONSE_CODE varchar binary,
	RETURN_REASON varchar,
	RETURN_FEE_AMOUNT int(11),
	LATE_FEE_AMOUNT int(11),
	PAYMENT_PLAN_CODE varchar,
	PAYMENT_PLAN_AMOUNT int(11),
	FIRST_BILLING_DATE datetime,
	NEXT_BILLING_DATE datetime,
	PAYMENT_OPTION_HOLDER_NAME varchar,
	PAYMENT_OPTION_TYPE varchar,
	PAYMENT_OPTION_NUMBER varchar,
	BALANCE_PHASE1 int(11),
	BALANCE_PHASE2 int(11),
	BALANCE_PHASE3 int(11),
	BALANCE_PHASE4 int(11),
	RESPONSE varchar,
	RETAIL_TRANSACTION_CYCLE_FK bigint(20),
	BATCH_FK bigint(20),
	SUB_BATCH_FK bigint(20),
	ATTACHMENT_CONTENT_SOURCE_CL varchar,
	CC_EMAIL varchar,
	IS_PLAIN_MESSAGE tinyint(1),
	FROM_EMAIL varchar,
	BILLING_STREET1 varchar,
	BILLING_STREET2 varchar,
	BILLING_CITY varchar,
	BILLING_STATE varchar,
	BILLING_ZIP_CODE varchar,
	BILLING_COUNTRY_CODE varchar,
	SHIPPING_STREET1 varchar,
	SHIPPING_STREET2 varchar,
	SHIPPING_CITY varchar,
	SHIPPING_STATE varchar,
	SHIPPING_ZIP_CODE varchar,
	SHIPPING_COUNTRY_CODE varchar,
	CUSTOMER_ACCOUNT_NOTES varchar,
	TRANSACTION_TYPE varchar,
	PAYMENT_PLAN_ITEM_DESCRIPTION varchar,
	TERMINAL_ORDER_FK bigint(20),
	BCC_EMAIL varchar,
	GENERIC_EMAIL_FK bigint(20),
	PRIMARY KEY (ID)
) ENGINE=InnoDB;