ALTER TABLE `order` ADD COLUMN `invDueDate`  datetime NOT NULL DEFAULT '0001-01-01 00:00:00' AFTER `orderDate`;
ALTER TABLE `order` ADD COLUMN `authorizedInXero`  tinyint(1) NOT NULL DEFAULT 0 AFTER `syncedWithXero`;
CREATE INDEX `invDueDate` ON `order`(`invDueDate`) USING BTREE ;
CREATE INDEX `authorizedInXero` ON `order`(`authorizedInXero`) USING BTREE ;

ALTER TABLE `customer` MODIFY COLUMN `terms`  int(2) NOT NULL DEFAULT 0 AFTER `email`;
ALTER TABLE `customer` ADD COLUMN `termsRuleId`  int(10) NULL DEFAULT NULL AFTER `terms`;

-- ----------------------------
-- Table structure for termsrule
-- ----------------------------
DROP TABLE IF EXISTS `termsrule`;
CREATE TABLE `termsrule` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(50) NOT NULL DEFAULT '',
  `nextMonth` tinyint(1) NOT NULL,
  `baseOnInvoice` tinyint(1) NOT NULL,
  `active` tinyint(1) NOT NULL DEFAULT '1',
  `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
  `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`),
  KEY `name` (`name`),
  KEY `createdById` (`createdById`),
  KEY `updatedById` (`updatedById`),
  KEY `nextMonth` (`nextMonth`) USING BTREE,
  KEY `baseOnInvoice` (`baseOnInvoice`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of termsrule
-- ----------------------------
INSERT INTO `termsrule` VALUES ('1', 'Of The Following Month', '1', '0', '1', '0001-01-01 00:00:00', '10', '2019-12-13 18:50:40', '10');
INSERT INTO `termsrule` VALUES ('2', 'Day(s) After The Bill Date', '0', '1', '1', '0001-01-01 00:00:00', '10', '2019-12-13 18:50:41', '10');
INSERT INTO `termsrule` VALUES ('3', 'Day(s) After The End Of The Bill Month', '1', '1', '0', '0001-01-01 00:00:00', '10', '2019-12-16 12:25:49', '10');

ALTER TABLE `product` ADD COLUMN `videoUrl`  varchar(120) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' AFTER `warranty`;
