Get orders working correctly
This commit is contained in:
@@ -101,35 +101,29 @@ CREATE TABLE product_categories (
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
-- Create orders table with its indexes
|
||||
CREATE TABLE orders (
|
||||
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
||||
CREATE TABLE IF NOT EXISTS orders (
|
||||
id BIGINT NOT NULL AUTO_INCREMENT,
|
||||
order_number VARCHAR(50) NOT NULL,
|
||||
pid BIGINT NOT NULL,
|
||||
SKU VARCHAR(50) NOT NULL,
|
||||
date DATE NOT NULL,
|
||||
price DECIMAL(10, 3) NOT NULL,
|
||||
price DECIMAL(10,3) NOT NULL,
|
||||
quantity INT NOT NULL,
|
||||
discount DECIMAL(10, 3) DEFAULT 0,
|
||||
tax DECIMAL(10, 3) DEFAULT 0,
|
||||
tax_included BOOLEAN DEFAULT false,
|
||||
shipping DECIMAL(10, 3) DEFAULT 0,
|
||||
discount DECIMAL(10,3) DEFAULT 0.000,
|
||||
tax DECIMAL(10,3) DEFAULT 0.000,
|
||||
tax_included TINYINT(1) DEFAULT 0,
|
||||
shipping DECIMAL(10,3) DEFAULT 0.000,
|
||||
customer VARCHAR(50) NOT NULL,
|
||||
customer_name VARCHAR(100),
|
||||
status VARCHAR(20) DEFAULT 'pending',
|
||||
payment_method VARCHAR(50),
|
||||
shipping_method VARCHAR(50),
|
||||
shipping_address TEXT,
|
||||
billing_address TEXT,
|
||||
canceled BOOLEAN DEFAULT false,
|
||||
FOREIGN KEY (pid) REFERENCES products(pid),
|
||||
INDEX idx_order_number (order_number),
|
||||
INDEX idx_customer (customer),
|
||||
INDEX idx_date (date),
|
||||
INDEX idx_status (status),
|
||||
INDEX idx_orders_metrics (pid, date, canceled, quantity, price),
|
||||
INDEX idx_orders_product_date (pid, date),
|
||||
UNIQUE KEY unique_order_product (order_number, pid)
|
||||
) ENGINE=InnoDB;
|
||||
canceled TINYINT(1) DEFAULT 0,
|
||||
PRIMARY KEY (id),
|
||||
KEY order_number (order_number),
|
||||
KEY pid (pid),
|
||||
KEY customer (customer),
|
||||
KEY date (date),
|
||||
KEY status (status)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- Create purchase_orders table with its indexes
|
||||
CREATE TABLE purchase_orders (
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user