Skip to content

Commit

Permalink
Added a 'status' field to the 'products' table to track whether a pro…
Browse files Browse the repository at this point in the history
…duct is active or discontinued.
  • Loading branch information
GitHub Gen Changes committed Jul 23, 2024
1 parent 441f596 commit 4c01fee
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 2 additions & 0 deletions dirs/ecommerce/migrations/20240723130918.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Modify "products" table
ALTER TABLE `products` ADD COLUMN `status` varchar(50) NOT NULL DEFAULT "active";
3 changes: 2 additions & 1 deletion dirs/ecommerce/migrations/atlas.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
h1:KveoiKu4HyWUI47T4AqboduRzzGX3kTN9YrCc7fVW2I=
h1:FhCmEtNeFxLzLPvH5DIoNYftWU4r0H8Oh1qtGd/hijU=
20230316085611.sql h1:br6W6LPEnnsejlz/7hRm9zthwStCzjN2vZkqVPxlmvo=
20230316090502.sql h1:GfeRjkSeoCt3JVRtLQNa/r50lRfpAPXS7AqTU2ZNFgY=
20230531091333_products_categories.sql h1:59q2M59dV5dJNv4Lyb2TAJz8V6HekgkLn9z4DoL98jA=
Expand All @@ -25,3 +25,4 @@ h1:KveoiKu4HyWUI47T4AqboduRzzGX3kTN9YrCc7fVW2I=
20240716130659.sql h1:/Dz+XBDPkPvfnBuS9JbsQ8lZN3GfjWtcn3p1WeDtRvk=
20240718130908.sql h1:48TPrpE8Tr3qkT0Gkt1d4mjY3vVAIziSfr6Dswia9MQ=
20240721130705.sql h1:PeB5YebwZvu8tQrL6vMrPtL/PVLsgkZrw15bQx8Z/cc=
20240723130918.sql h1:7UFf+5hmmm/hJZdmF1lvHCz+GYQKbSkxAUK6Q41kVXs=
21 changes: 11 additions & 10 deletions dirs/ecommerce/schema.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Create "users" table
-- Create 'users' table
CREATE TABLE `users` (
`id` int NOT NULL,
`user_name` varchar(255) NOT NULL,
Expand All @@ -15,28 +15,29 @@ PRIMARY KEY (`id`),
UNIQUE INDEX `email` (`email`)
) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;

-- Create "categories" table
-- Create 'categories' table
CREATE TABLE `categories` (
`id` int NOT NULL,
`category_name` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;

-- Create "products" table
-- Create 'products' table
CREATE TABLE `products` (
`id` int NOT NULL,
`product_name` varchar(255) NOT NULL,
`price` decimal(10,2) NOT NULL,
`category_id` int NULL,
`description` text NULL,
`featured` bool NOT NULL DEFAULT 0,
`status` varchar(50) NOT NULL DEFAULT 'active',
PRIMARY KEY (`id`),
INDEX `category_id` (`category_id`),
UNIQUE INDEX `product_name` (`product_name`),
CONSTRAINT `products_ibfk_1` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) ON UPDATE NO ACTION ON DELETE SET NULL
) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;

-- Create "product_reviews" table
-- Create 'product_reviews' table
CREATE TABLE `product_reviews` (
`id` int NOT NULL,
`product_id` int NOT NULL,
Expand All @@ -50,7 +51,7 @@ CONSTRAINT `product_reviews_ibfk_1` FOREIGN KEY (`product_id`) REFERENCES `produ
CONSTRAINT `product_reviews_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE
) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;

-- Create "comments" table
-- Create 'comments' table
CREATE TABLE `comments` (
`id` int NOT NULL,
`user_id` int NOT NULL,
Expand All @@ -66,15 +67,15 @@ CONSTRAINT `comments_ibfk_2` FOREIGN KEY (`review_id`) REFERENCES `product_revie
CONSTRAINT `comments_ibfk_3` FOREIGN KEY (`parent_comment_id`) REFERENCES `comments` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE
) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;

-- Create "fulfillment_centers" table
-- Create 'fulfillment_centers' table
CREATE TABLE `fulfillment_centers` (
`id` int NOT NULL,
`name` varchar(255) NOT NULL,
`location` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;

-- Create "inventory" table
-- Create 'inventory' table
CREATE TABLE `inventory` (
`id` int NOT NULL,
`product_id` int NOT NULL,
Expand All @@ -87,7 +88,7 @@ CONSTRAINT `inventory_ibfk_1` FOREIGN KEY (`product_id`) REFERENCES `products` (
CONSTRAINT `inventory_ibfk_2` FOREIGN KEY (`fulfillment_center_id`) REFERENCES `fulfillment_centers` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE
) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;

-- Create "orders" table
-- Create 'orders' table
CREATE TABLE `orders` (
`id` int NOT NULL,
`user_id` int NOT NULL,
Expand All @@ -104,7 +105,7 @@ CONSTRAINT `orders_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON
CONSTRAINT `orders_ibfk_2` FOREIGN KEY (`fulfillment_center_id`) REFERENCES `fulfillment_centers` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE
) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;

-- Create "order_items" table
-- Create 'order_items' table
CREATE TABLE `order_items` (
`id` int NOT NULL,
`order_id` int NOT NULL,
Expand All @@ -118,7 +119,7 @@ CONSTRAINT `order_items_ibfk_1` FOREIGN KEY (`order_id`) REFERENCES `orders` (`i
CONSTRAINT `order_items_ibfk_2` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE
) CHARSET utf8mb4 COLLATE utf8mb4_0900_ai_ci;

-- Create "posts" table
-- Create 'posts' table
CREATE TABLE `posts` (
`id` int NOT NULL,
`user_id` int NOT NULL,
Expand Down

0 comments on commit 4c01fee

Please sign in to comment.