alter table `customer`
  add column `creditPoints` double(8,2) NOT NULL DEFAULT 0 after `tierId`;
CREATE INDEX `creditPoints` ON `customer`(`creditPoints`) USING BTREE ;

INSERT INTO systemsettings (type, value, description, active, created, createdById, updated, updatedById)
VALUES ('credit_points_conversion_ratio', '', 'Conversion / Redemption Ratio of credit points ({"conversion" : 1, "redemption" : 10, "limit" : 50000}, 1 means $1 = 1 point, 10 means 10 points = $1)', '1', UTC_TIMESTAMP, '10', UTC_TIMESTAMP, '10');

INSERT INTO product (`sku`, `name`, `isSystemDefault`, `active`, `created`, `createdById`, `updated`, `updatedById`)
VALUES ('Credit-Points', 'Credit Points', 1, 0, NOW(), 10, NOW(), 10);

DROP TABLE IF EXISTS `creditpointslog`;
CREATE TABLE `creditpointslog` (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `customerId` int(10) NOT NULL DEFAULT 0,
  `paymentId` int(10) NULL,
  `creditNoteId` int(10) NULL,
  `points` double(8,2) NOT NULL DEFAULT 0.00,
  `active` tinyint(1) NOT NULL DEFAULT 1,
  `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `createdById` int(10) UNSIGNED NOT NULL DEFAULT 0 ,
  `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `updatedById` int(10) UNSIGNED NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  INDEX `customerId` (`customerId`) USING BTREE,
  INDEX `paymentId` (`paymentId`) USING BTREE,
  INDEX `points` (`points`) USING BTREE,
  INDEX `active` (`active`) USING BTREE,
  INDEX `created` (`created`) USING BTREE,
  INDEX `createdById` (`createdById`) USING BTREE,
  INDEX `updated` (`updated`) USING BTREE,
  INDEX `updatedById` (`updatedById`) USING BTREE
)ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;


ALTER TABLE `customer` DROP INDEX `groupCom`;
ALTER TABLE `customer` DROP INDEX `groupEdu`;
ALTER TABLE `customer` DROP INDEX `groupGame`;
ALTER TABLE `customer` DROP INDEX `groupGen`;
ALTER TABLE `customer` DROP INDEX `optout`;
ALTER TABLE `customer` DROP INDEX `bounced`;
ALTER TABLE `customer` DROP COLUMN `groupCom`;
ALTER TABLE `customer` DROP COLUMN `groupEdu`;
ALTER TABLE `customer` DROP COLUMN `groupGame`;
ALTER TABLE `customer` DROP COLUMN `groupGen`;
ALTER TABLE `customer` DROP COLUMN `optout`;
ALTER TABLE `customer` DROP COLUMN `bounced`;
ALTER TABLE `customer` DROP COLUMN `customerGroups`;
