add carts

This commit is contained in:
Daniel Goc
2026-03-24 14:46:38 +01:00
parent 04538d4373
commit c464c02301
8 changed files with 303 additions and 13 deletions

View File

@@ -86,18 +86,27 @@ CREATE INDEX IF NOT EXISTS idx_customers_deleted_at
ON b2b_customers (deleted_at);
-- customer_repo_accesses
-- CREATE TABLE IF NOT EXISTS b2b_customer_repo_accesses (
-- user_id BIGINT NOT NULL,
-- repo_id BIGINT NOT NULL,
-- PRIMARY KEY (user_id, repo_id),
-- CONSTRAINT fk_customer_repo_user
-- FOREIGN KEY (user_id) REFERENCES b2b_customers(id)
-- ON DELETE CASCADE,
-- CONSTRAINT fk_customer_repo_repo
-- FOREIGN KEY (repo_id) REFERENCES repository(id)
-- ON DELETE CASCADE
-- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- customer_carts
CREATE TABLE IF NOT EXISTS b2b_customer_carts (
cart_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
user_id BIGINT UNSIGNED NOT NULL,
name VARCHAR(255) NULL,
CONSTRAINT fk_customer_carts_customers FOREIGN KEY (user_id) REFERENCES b2b_customers(id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;
CREATE INDEX IF NOT EXISTS idx_customer_carts_user_id ON b2b_customer_carts (user_id);
-- carts_products
CREATE TABLE IF NOT EXISTS b2b_carts_products (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
cart_id BIGINT UNSIGNED NOT NULL,
product_id INT UNSIGNED NOT NULL,
product_attribute_id BIGINT NULL,
amount INT NOT NULL,
CONSTRAINT fk_carts_products_customer_carts FOREIGN KEY (cart_id) REFERENCES b2b_customer_carts (cart_id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT fk_carts_products_product FOREIGN KEY (product_id) REFERENCES ps_product (id_product) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;
CREATE INDEX IF NOT EXISTS idx_carts_products_cart_id ON b2b_carts_products (cart_id);
-- refresh_tokens