14 lines
597 B
SQL
14 lines
597 B
SQL
-- Create the orders table
|
|
CREATE TABLE IF NOT EXISTS `orders` (
|
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
|
`customer_id` INT NOT NULL,
|
|
`plan_id` INT NOT NULL,
|
|
`order_status` VARCHAR(50) NOT NULL DEFAULT 'pending', -- e.g., pending, active, cancelled
|
|
`total_amount` DECIMAL(10, 2) NOT NULL,
|
|
`order_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
`activation_date` DATE NULL,
|
|
`notes` TEXT NULL,
|
|
FOREIGN KEY (`customer_id`) REFERENCES `customers`(`id`) ON DELETE CASCADE,
|
|
FOREIGN KEY (`plan_id`) REFERENCES `plans`(`id`) ON DELETE RESTRICT
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|