init
This commit is contained in:
commit
12ae64d4e8
|
@ -0,0 +1,2 @@
|
|||
docker exec d4dd199a4566 pg_dump -U postgres postgres > $(pwd)/backups/$(date -d "today" +"%Y-%m-%d-%H-%M").sql
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
services:
|
||||
postgreSQL:
|
||||
container_name: dengadiplom
|
||||
environment:
|
||||
POSTGRES_PASSWORD: not_admin
|
||||
image: postgres
|
||||
ports:
|
||||
- 6000:5432
|
||||
volumes:
|
||||
- ./postgres-data:/var/lib/postgresql/data
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
SET lc_monetary TO 'ru_RU.UTF-8';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS clients (
|
||||
client_id SERIAL PRIMARY KEY,
|
||||
surname VARCHAR(50) NOT NULL,
|
||||
forename VARCHAR(50) NOT NULL,
|
||||
patronymic VARCHAR(50),
|
||||
age SMALLINT,
|
||||
phone_number VARCHAR(15) NOT NULL,
|
||||
email VARCHAR(50) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS auth (
|
||||
client_id INT PRIMARY KEY REFERENCES clients(client_id),
|
||||
password VARCHAR(50) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS board_games (
|
||||
board_game_id SERIAL PRIMARY KEY,
|
||||
name VARCHAR(100) NOT NULL,
|
||||
genre VARCHAR(30),
|
||||
publisher VARCHAR(50),
|
||||
price MONEY NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS sections (
|
||||
section_id SERIAL PRIMARY KEY,
|
||||
name VARCHAR(20) NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS sections_board_games (
|
||||
section_id INT REFERENCES sections(section_id),
|
||||
board_game_id INT REFERENCES board_games(board_game_id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS bags (
|
||||
bag_id SERIAL PRIMARY KEY,
|
||||
client_id INT REFERENCES clients(client_id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS bags_board_games (
|
||||
bag_id INT REFERENCES bags(bag_id),
|
||||
board_game_id INT REFERENCES board_games(board_game_id),
|
||||
count INT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS discounts (
|
||||
discount_id SERIAL PRIMARY KEY,
|
||||
board_game_id INT REFERENCES board_games(board_game_id),
|
||||
amount SMALLINT NOT NULL,
|
||||
valid_until TIMESTAMP NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS clients_discounts (
|
||||
discount INT REFERENCES discounts(discount_id),
|
||||
client_id INT REFERENCES clients(client_id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS wishlists (
|
||||
wishlist_id SERIAL PRIMARY KEY,
|
||||
client_id INT REFERENCES clients(client_id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS wishlists_games (
|
||||
wishlist_id INT REFERENCES wishlists(wishlist_id),
|
||||
board_game_id INT REFERENCES board_games(board_game_id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS orders (
|
||||
order_id SERIAL PRIMARY KEY,
|
||||
client_id INT REFERENCES clients(client_id),
|
||||
pick_up VARCHAR(50) NOT NULL,
|
||||
order_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
cost MONEY NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS orders_games (
|
||||
order_id INT REFERENCES orders(order_id),
|
||||
board_game_id INT REFERENCES board_games(board_game_id),
|
||||
discount_id INT REFERENCES discounts(discount_id),
|
||||
count INT NOT NULL
|
||||
);
|
|
@ -0,0 +1,162 @@
|
|||
INSERT INTO clients (surname, forename, patronymic, age, phone_number, email) VALUES
|
||||
('Иванов', 'Иван', 'Иванович', 28, '+79876543210', 'ivanov@example.com'),
|
||||
('Петрова', 'Мария', NULL, 34, '+79876543211', 'petrova@example.com'),
|
||||
('Сидоров', 'Алексей', 'Викторович', 22, '+79876543212', 'sidorov@example.com'),
|
||||
('Кузнецова', 'Екатерина', 'Андреевна', 26, '+79876543213', 'kuznetsova@example.com'),
|
||||
('Васильев', 'Дмитрий', 'Олегович', 31, '+79876543214', 'vasiliev@example.com'),
|
||||
('Смирнова', 'Анна', 'Игоревна', 29, '+79876543215', 'smirnova@example.com'),
|
||||
('Орлов', 'Павел', 'Владимирович', 35, '+79876543216', 'orlov@example.com'),
|
||||
('Михайлова', 'Ольга', 'Николаевна', 24, '+79876543217', 'mikhailova@example.com');
|
||||
|
||||
INSERT INTO auth (client_id, password) VALUES
|
||||
(1, 'password123'),
|
||||
(2, 'qwerty456'),
|
||||
(3, 'securepass789'),
|
||||
(4, 'pass456'),
|
||||
(5, 'mysecurepass'),
|
||||
(6, 'easy123'),
|
||||
(7, 'orlovpass'),
|
||||
(8, 'mikhailova987');
|
||||
|
||||
INSERT INTO board_games (name, genre, publisher, price) VALUES
|
||||
('Монополия', 'Экономическая стратегия', 'Hasbro', 1999.99),
|
||||
('Мафия', 'Социальная игра', 'Hobby World', 899.00),
|
||||
('Каркассон', 'Стратегия', 'Z-Man Games', 1499.50),
|
||||
('Эволюция', 'Образовательная', 'Правильные игры', 1299.00),
|
||||
('Диксит', 'Творческая', 'Libellud', 2299.00),
|
||||
('7 Чудес', 'Карточная стратегия', 'Repos Production', 2599.00),
|
||||
('Кодовое имя', 'Ассоциативная', 'Czech Games', 1599.00),
|
||||
('Бэнг!', 'Вестерн', 'dV Giochi', 1399.00),
|
||||
('Колонизаторы', 'Экономическая стратегия', 'Kosmos', 2799.00),
|
||||
('Тикет ту райд', 'Путешествия', 'Days of Wonder', 3499.00),
|
||||
('Агрикола', 'Фермерская стратегия', 'Z-Man Games', 2999.00),
|
||||
('Манчкин', 'Юмористическая', 'Steve Jackson Games', 1199.00),
|
||||
('Имаджинариум', 'Творческая', 'Stupid Casual', 1499.00),
|
||||
('Находка для шпиона', 'Детективная', 'Hobby World', 999.00),
|
||||
('Зельеварение', 'Фэнтези', 'Правильные игры', 1299.00),
|
||||
('Саботер', 'Кооперативная', 'Amigo', 999.00),
|
||||
('Цивилизация', 'Стратегия', 'Fantasy Flight Games', 3999.00),
|
||||
('Доминион', 'Стратегия', 'Rio Grande Games', 1899.00),
|
||||
('Терраформирование Марса', 'Космическая стратегия', 'FryxGames', 4599.00),
|
||||
('Гloomhaven', 'Ролевая', 'Cephalofair Games', 8999.00);
|
||||
|
||||
INSERT INTO sections (name) VALUES
|
||||
('Хиты продаж'),
|
||||
('Новинки'),
|
||||
('Семейные'),
|
||||
('Для детей'),
|
||||
('Для вечеринок'),
|
||||
('Стратегии'),
|
||||
('Кооперативные'),
|
||||
('Фэнтези'),
|
||||
('Космические');
|
||||
|
||||
INSERT INTO sections_board_games (section_id, board_game_id) VALUES
|
||||
(1, 1), (1, 3), (1, 5), (1, 10),
|
||||
(2, 2), (2, 7), (2, 18),
|
||||
(3, 1), (3, 4), (3, 9),
|
||||
(4, 4), (4, 12), (4, 13),
|
||||
(5, 2), (5, 5), (5, 8),
|
||||
(6, 3), (6, 9), (6, 18),
|
||||
(7, 14), (7, 16),
|
||||
(8, 15), (8, 19),
|
||||
(9, 17), (9, 20);
|
||||
|
||||
INSERT INTO discounts (board_game_id, amount, valid_until) VALUES
|
||||
(1, 600, '2024-12-31 23:59:59'),
|
||||
(3, 300, '2024-12-25 23:59:59'),
|
||||
(5, 450, '2024-12-31 23:59:59'),
|
||||
(9, 750, '2025-01-15 23:59:59'),
|
||||
(14, 900, '2025-02-01 23:59:59'),
|
||||
(18, 600, '2024-12-31 23:59:59'),
|
||||
(20, 300, '2025-01-10 23:59:59');
|
||||
|
||||
INSERT INTO clients_discounts (discount, client_id) VALUES
|
||||
(1, 1),
|
||||
(2, 2),
|
||||
(3, 3),
|
||||
(4, 4),
|
||||
(5, 5),
|
||||
(6, 6),
|
||||
(7, 7);
|
||||
|
||||
INSERT INTO bags (client_id) VALUES
|
||||
(1),
|
||||
(2),
|
||||
(3),
|
||||
(4),
|
||||
(5),
|
||||
(6),
|
||||
(7),
|
||||
(8);
|
||||
|
||||
INSERT INTO bags_board_games (bag_id, board_game_id, count) VALUES
|
||||
(1, 1, 1),
|
||||
(1, 3, 2),
|
||||
(2, 2, 1),
|
||||
(2, 5, 1),
|
||||
(3, 6, 2),
|
||||
(3, 10, 1),
|
||||
(4, 7, 1),
|
||||
(5, 8, 2),
|
||||
(6, 9, 1),
|
||||
(7, 11, 3),
|
||||
(8, 20, 1);
|
||||
|
||||
INSERT INTO wishlists (client_id) VALUES
|
||||
(1),
|
||||
(1),
|
||||
(1),
|
||||
(4),
|
||||
(5),
|
||||
(6),
|
||||
(7),
|
||||
(8);
|
||||
|
||||
INSERT INTO wishlists_games (wishlist_id, board_game_id) VALUES
|
||||
(1, 4),
|
||||
(1, 5),
|
||||
(1, 9),
|
||||
(2, 1),
|
||||
(2, 14),
|
||||
(3, 2),
|
||||
(3, 3),
|
||||
(4, 7),
|
||||
(5, 15),
|
||||
(5, 18),
|
||||
(6, 12),
|
||||
(6, 19),
|
||||
(7, 6),
|
||||
(8, 17),
|
||||
(8, 20);
|
||||
|
||||
INSERT INTO orders (client_id, pick_up, cost) VALUES
|
||||
(1, 'Москва, Тверская 12', 4999.49),
|
||||
(2, 'Санкт-Петербург, Невский 88', 899.00),
|
||||
(3, 'Казань, Баумана 5', 3897.00),
|
||||
(4, 'Новосибирск, Ленина 10', 1499.00),
|
||||
(5, 'Екатеринбург, Малышева 45', 2399.00),
|
||||
(6, 'Краснодар, Красная 22', 2999.00),
|
||||
(7, 'Воронеж, Плехановская 5', 1299.00),
|
||||
(8, 'Нижний Новгород, Рождественская 12', 4599.00),
|
||||
(1, 'Москва, Тверская 12', 1599.00),
|
||||
(3, 'Казань, Баумана 5', 3599.00),
|
||||
(5, 'Екатеринбург, Малышева 45', 3499.00),
|
||||
(7, 'Воронеж, Плехановская 5', 1299.00),
|
||||
(8, 'Нижний Новгород, Рождественская 12', 5299.00);
|
||||
|
||||
INSERT INTO orders_games (order_id, board_game_id, discount_id, count) VALUES
|
||||
(1, 1, 1, 1),
|
||||
(1, 3, 2, 2),
|
||||
(2, 2, NULL, 1),
|
||||
(3, 5, 3, 3),
|
||||
(4, 6, NULL, 1),
|
||||
(5, 8, 4, 2),
|
||||
(6, 9, 5, 1),
|
||||
(7, 11, NULL, 1),
|
||||
(8, 18, 6, 1),
|
||||
(9, 3, 2, 1),
|
||||
(10, 10, NULL, 1),
|
||||
(11, 20, 7, 1),
|
||||
(12, 12, NULL, 1),
|
||||
(13, 14, NULL, 1);
|
|
@ -0,0 +1,2 @@
|
|||
(crontab -l 2>/dev/null; echo "* */12 * * * $(pwd)/backup.sh") | crontab -
|
||||
|
Loading…
Reference in New Issue