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