Skip to content

Commit

Permalink
generate db script
Browse files Browse the repository at this point in the history
  • Loading branch information
souravroy committed Nov 11, 2024
1 parent 10e4177 commit 59ec03a
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
30 changes: 30 additions & 0 deletions api-rest/src/test/resources/pg/postgres-sakila-data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -323,3 +323,33 @@ Insert into film_category
(film_id,category_id,last_update)
Values
('4','11','2006-02-15 05:07:09.000');

-- product

INSERT INTO product (name, description, price)
VALUES
('Smartphone X', 'A high-end smartphone with OLED display and 5G connectivity', 799.99),
('Wireless Earbuds Pro', 'Noise cancelling wireless earbuds with high quality sound', 799.99),
('Smartwatch Fit', 'Fitness-focused smartwatch with heart-rate monitoring and GPS', 799.99);

-- product_variant

INSERT INTO product_variant (product_id, variant_name, SKU, price, stock_quantity)
VALUES
(1, 'Smartphone X - 128GB', 'SKU_SX128', 799.99, 100),
(1, 'Smartphone X - 256GB', 'SKU_SX256', 899.99, 50),
(2, 'Wireless Earbuds Pro - Black', 'SKU_WEPB', 199.99, 200),
(2, 'Wireless Earbuds Pro - White', 'SKU_WEPW', 199.99, 75),
(3, 'Smartwatch Fit - Small', 'SKU_SWS', 149.99, 150),
(3, 'Smartwatch Fit - Large', 'SKU_SWL', 149.99, 100);

-- tags

INSERT INTO tags (product_id, tag_name)
VALUES
(1, 'Electronics'),
(1, 'Smart Devices'),
(2, 'Audio'),
(2, 'Wireless'),
(3, 'Wearable'),
(3, 'Fitness');
40 changes: 40 additions & 0 deletions api-rest/src/test/resources/pg/postgres-sakila.sql
Original file line number Diff line number Diff line change
Expand Up @@ -552,3 +552,43 @@ AS $$
END;
$$;
-- select GetMovieRentalRateFunc('ACADEMY DINOSAUR');

--
-- Table structure for table `product`
--
CREATE TABLE product (
product_id SERIAL PRIMARY KEY,
name varchar(255) NOT NULL,
description TEXT,
price DECIMAL(10, 2) NOT NULL,
createdat TIMESTAMP DEFAULT NOW() NOT NULL,
updatedat TIMESTAMP DEFAULT NOW() NOT NULL
);

--
-- Table structure for table `product_variant`
--

CREATE TABLE product_variant (
variant_id SERIAL PRIMARY KEY,
product_id INT NOT NULL,
variant_name varchar(255) NOT NULL,
SKU VARCHAR(100) UNIQUE NOT NULL,
price DECIMAL(10, 2) NOT NULL,
stock_quantity INT DEFAULT 0,
createdat TIMESTAMP DEFAULT NOW() NOT NULL,
updatedat TIMESTAMP DEFAULT NOW() NOT NULL,
FOREIGN KEY (product_id) REFERENCES product(product_id) ON DELETE CASCADE
);

--
-- Table structure for table `tags`
--

CREATE TABLE tags (
tag_id SERIAL PRIMARY KEY,
product_id INT NOT NULL,
tag_name varchar(100) NOT NULL,
createdat TIMESTAMP DEFAULT NOW() NOT NULL,
FOREIGN KEY (product_id) REFERENCES product(product_id) ON DELETE CASCADE
);

0 comments on commit 59ec03a

Please sign in to comment.