mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-03-06 08:11:12 -05:00
Add database foreign keys related to rewards
This commit is contained in:
@@ -117,7 +117,8 @@ CREATE TABLE `ospos_customers` (
|
||||
`points` int(11) DEFAULT NULL,
|
||||
`deleted` int(1) NOT NULL DEFAULT '0',
|
||||
UNIQUE KEY `account_number` (`account_number`),
|
||||
KEY `person_id` (`person_id`)
|
||||
KEY `person_id` (`person_id`),
|
||||
KEY `package_id` (`package_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
--
|
||||
@@ -923,7 +924,10 @@ CREATE TABLE IF NOT EXISTS `ospos_customers_points` (
|
||||
`package_id` int(11) NOT NULL,
|
||||
`sale_id` int(11) NOT NULL,
|
||||
`points_earned` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `person_id` (`person_id`),
|
||||
KEY `package_id` (`package_id`),
|
||||
KEY `sale_id` (`sale_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
|
||||
|
||||
|
||||
@@ -938,7 +942,8 @@ CREATE TABLE IF NOT EXISTS `ospos_sales_reward_points` (
|
||||
`sale_id` int(11) NOT NULL,
|
||||
`earned` float NOT NULL,
|
||||
`used` float NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `sale_id` (`sale_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
|
||||
|
||||
|
||||
@@ -952,7 +957,8 @@ CREATE TABLE IF NOT EXISTS `ospos_sales_reward_points` (
|
||||
-- Constraints for table `ospos_customers`
|
||||
--
|
||||
ALTER TABLE `ospos_customers`
|
||||
ADD CONSTRAINT `ospos_customers_ibfk_1` FOREIGN KEY (`person_id`) REFERENCES `ospos_people` (`person_id`);
|
||||
ADD CONSTRAINT `ospos_customers_ibfk_1` FOREIGN KEY (`person_id`) REFERENCES `ospos_people` (`person_id`),
|
||||
ADD CONSTRAINT `ospos_customers_ibfk_2` FOREIGN KEY (`package_id`) REFERENCES `ospos_customers_packages` (`package_id`);
|
||||
|
||||
--
|
||||
-- Constraints for table `ospos_employees`
|
||||
@@ -1092,3 +1098,16 @@ ALTER TABLE `ospos_suppliers`
|
||||
ALTER TABLE `ospos_giftcards`
|
||||
ADD CONSTRAINT `ospos_giftcards_ibfk_1` FOREIGN KEY (`person_id`) REFERENCES `ospos_people` (`person_id`);
|
||||
|
||||
--
|
||||
-- Constraints for table `ospos_customers_points`
|
||||
--
|
||||
ALTER TABLE `ospos_customers_points`
|
||||
ADD CONSTRAINT `ospos_customers_points_ibfk_1` FOREIGN KEY (`person_id`) REFERENCES `ospos_customers` (`person_id`),
|
||||
ADD CONSTRAINT `ospos_customers_points_ibfk_2` FOREIGN KEY (`package_id`) REFERENCES `ospos_customers_packages` (`package_id`),
|
||||
ADD CONSTRAINT `ospos_customers_points_ibfk_3` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales_items` (`sale_id`);
|
||||
|
||||
--
|
||||
-- Constraints for table `ospos_sales_reward_points`
|
||||
--
|
||||
ALTER TABLE `ospos_sales_reward_points`
|
||||
ADD CONSTRAINT `ospos_sales_reward_points_ibfk_1` FOREIGN KEY (`sale_id`) REFERENCES `ospos_sales_items` (`sale_id`);
|
||||
|
||||
Reference in New Issue
Block a user