Merge branch 'main' of ssh://git.ma-al.com:8822/goc_daniel/b2b into no-vat-customers

This commit is contained in:
2026-04-14 13:36:11 +02:00
45 changed files with 1115 additions and 405 deletions

View File

@@ -131,7 +131,7 @@ FOREIGN KEY (role_id) REFERENCES b2b_roles(id);
-- customer_carts
CREATE TABLE IF NOT EXISTS b2b_customer_carts (
cart_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
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
@@ -141,8 +141,8 @@ CREATE INDEX IF NOT EXISTS idx_customer_carts_user_id ON b2b_customer_carts (use
-- carts_products
CREATE TABLE IF NOT EXISTS b2b_carts_products (
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
cart_id INT UNSIGNED NOT NULL,
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
cart_id BIGINT UNSIGNED NOT NULL,
product_id INT UNSIGNED NOT NULL,
product_attribute_id INT NULL,
amount INT UNSIGNED NOT NULL,
@@ -225,7 +225,7 @@ ON `b2b_countries` (
CREATE TABLE IF NOT EXISTS b2b_addresses (
id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL,
b2b_customer_id BIGINT UNSIGNED NOT NULL,
address_info TEXT NOT NULL,
address_string TEXT NOT NULL,
b2b_country_id BIGINT UNSIGNED NOT NULL,
PRIMARY KEY (id),
CONSTRAINT fk_b2b_addresses_b2b_customers FOREIGN KEY (b2b_customer_id) REFERENCES b2b_customers (id) ON DELETE CASCADE ON UPDATE CASCADE,
@@ -233,6 +233,34 @@ CREATE TABLE IF NOT EXISTS b2b_addresses (
) ENGINE = InnoDB;
-- customer_orders
CREATE TABLE IF NOT EXISTS b2b_customer_orders (
order_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
user_id BIGINT UNSIGNED NOT NULL,
name TEXT NOT NULL,
country_id BIGINT UNSIGNED NOT NULL,
address_string TEXT NOT NULL,
status VARCHAR(50) NOT NULL,
CONSTRAINT fk_customer_orders_customers FOREIGN KEY (user_id) REFERENCES b2b_customers(id) ON DELETE NO ACTION ON UPDATE CASCADE,
CONSTRAINT fk_customer_orders_countries FOREIGN KEY (country_id) REFERENCES b2b_countries(id) ON DELETE NO ACTION ON UPDATE CASCADE
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;
CREATE INDEX idx_customer_orders_user_id ON b2b_customer_orders (user_id);
CREATE INDEX idx_customer_orders_country_id ON b2b_customer_orders (country_id);
-- orders_products
CREATE TABLE IF NOT EXISTS b2b_orders_products (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
order_id BIGINT UNSIGNED NOT NULL,
product_id INT UNSIGNED NOT NULL,
product_attribute_id INT NULL,
amount INT UNSIGNED NOT NULL,
CONSTRAINT fk_orders_products_customer_orders FOREIGN KEY (order_id) REFERENCES b2b_customer_orders (order_id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT fk_orders_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_orders_products_order_id ON b2b_orders_products (order_id);
CREATE TABLE b2b_specific_price (
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
@@ -403,16 +431,26 @@ DELIMITER ;
-- +goose Down
DROP TABLE IF EXISTS b2b_countries;
DROP TABLE IF EXISTS b2b_language;
DROP TABLE IF EXISTS b2b_components;
DROP TABLE IF EXISTS b2b_scopes;
DROP TABLE IF EXISTS b2b_translations;
DROP TABLE IF EXISTS b2b_customers;
DROP TABLE IF EXISTS b2b_refresh_tokens;
DROP TABLE IF EXISTS b2b_currencies;
DROP TABLE IF EXISTS b2b_currency_rates;
DROP TABLE IF EXISTS b2b_specific_price;
DROP TABLE IF EXISTS b2b_specific_price_product;
DROP TABLE IF EXISTS b2b_specific_price_category;
DROP TABLE IF EXISTS b2b_addresses;
DROP TABLE IF EXISTS b2b_top_menu_roles;
DROP TABLE IF EXISTS b2b_favorites;
DROP TABLE IF EXISTS b2b_carts_products;
DROP TABLE IF EXISTS b2b_customer_carts;
DROP TABLE IF EXISTS b2b_specific_price_country;
DROP TABLE IF EXISTS b2b_specific_price_customer;
DROP TABLE IF EXISTS b2b_specific_price_product_attribute;
DROP TABLE IF EXISTS b2b_specific_price_category;
DROP TABLE IF EXISTS b2b_specific_price_product;
DROP TABLE IF EXISTS b2b_specific_price;
DROP TABLE IF EXISTS b2b_role_permissions;
DROP TABLE IF EXISTS b2b_permissions;
DROP TABLE IF EXISTS b2b_roles;
DROP TABLE IF EXISTS b2b_countries;
DROP TABLE IF EXISTS b2b_currency_rates;
DROP TABLE IF EXISTS b2b_currencies;
DROP TABLE IF EXISTS b2b_refresh_tokens;
DROP TABLE IF EXISTS b2b_customers;
DROP TABLE IF EXISTS b2b_translations;
DROP TABLE IF EXISTS b2b_scopes;
DROP TABLE IF EXISTS b2b_components;
DROP TABLE IF EXISTS b2b_language;