36782-vm/db/migrations/018_create_product_attributes_table.sql
2025-12-12 14:13:03 +00:00

12 lines
533 B
SQL

CREATE TABLE IF NOT EXISTS product_attributes (
id INT AUTO_INCREMENT PRIMARY KEY,
product_id INT NOT NULL,
attribute_key_id INT NOT NULL,
value TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (product_id) REFERENCES products(id) ON DELETE CASCADE,
FOREIGN KEY (attribute_key_id) REFERENCES attribute_keys(id) ON DELETE CASCADE,
UNIQUE KEY `product_attribute` (product_id, attribute_key_id)
);