· 6 years ago · Oct 12, 2019, 02:56 PM
1DROP DATABASE simplebooking;
2CREATE DATABASE IF NOT EXISTS `simplebooking`;
3
4USE `simplebooking`;
5
6SET FOREIGN_KEY_CHECKS=0;
7
8CREATE TABLE `users` (
9 id int(11) NOT NULL AUTO_INCREMENT,
10 username varchar(255) NOT NULL,
11 email varchar(255) NOT NULL,
12 password varchar(255) NOT NULL,
13 enabled int(11) DEFAULT 0,
14 created_at datetime,
15 modified_at datetime,
16 removed_at datetime,
17 PRIMARY KEY (id)
18) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
19
20CREATE TABLE `authorities` (
21 id int(11) NOT NULL AUTO_INCREMENT,
22 user_id int(11) NOT NULL,
23 username varchar(255) NOT NULL,
24 authority varchar(50) NOT NULL,
25 PRIMARY KEY (id),
26 FOREIGN KEY (user_id) REFERENCES users(id)
27) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
28
29CREATE TABLE `places` (
30 id int(11) NOT NULL AUTO_INCREMENT,
31 user_id int(11) NOT NULL,
32 name varchar(255) NOT NULL,
33 address varchar(255) NOT NULL,
34 large_description varchar(255) NOT NULL,
35 small_description varchar(50) NOT NULL,
36 created_at datetime,
37 modified_at datetime,
38 removed_at datetime,
39 PRIMARY KEY (id),
40 FOREIGN KEY (user_id) REFERENCES users(id)
41) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
42
43CREATE TABLE `place_urls` (
44 id int(11) NOT NULL AUTO_INCREMENT,
45 place_id int(11) NOT NULL,
46 url varchar(255) NOT NULL,
47 created_at datetime,
48 modified_at datetime,
49 removed_at datetime,
50 PRIMARY KEY (id),
51 FOREIGN KEY (place_id) REFERENCES places(id)
52) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
53
54CREATE TABLE `bookings` (
55 id int(11) NOT NULL AUTO_INCREMENT,
56 place_id int(11) NOT NULL,
57 name varchar(255) NOT NULL,
58 phonenumber varchar(255) NOT NULL,
59 reservation_date date NOT NULL,
60 receipt_number varchar(25) NOT NULL,
61 created_at datetime,
62 modified_at datetime,
63 removed_at datetime,
64 PRIMARY KEY (id),
65 FOREIGN KEY (place_id) REFERENCES places(id)
66) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
67
68-- users
69insert into users (username, email, password, enabled) VALUES ('admin', 'admin@simplebooking.com', '$2a$10$0MMwY.IQqpsVc1jC8u7IJ.2rT8b0Cd3b3sfIBGV2zfgnPGtT4r0.C', 1);
70insert into users (username, email, password, enabled) VALUES ('user', 'user@simplebooking.com', '$2a$06$3jYRJrg0ghaaypjZ/.g4SethoeA51ph3UD4kZi9oPkeMTpjKU5uo6', 1);
71insert into users (username, email, password, enabled) VALUES ('user2', 'user2@simplebooking.com', '$2a$06$3jYRJrg0ghaaypjZ/.g4SethoeA51ph3UD4kZi9oPkeMTpjKU5uo6', 1);
72insert into users (username, email, password, enabled) VALUES ('user3', 'user3@simplebooking.com', '$2a$06$3jYRJrg0ghaaypjZ/.g4SethoeA51ph3UD4kZi9oPkeMTpjKU5uo6', 0);
73insert into users (username, email, password, enabled, removed_at) VALUES ('kovaluu', 'kovaluu@tulinpelleilee.fi', '$2a$06$3jYRJrg0ghaaypjZ/.g4SethoeA51ph3UD4kZi9oPkeMTpjKU5uo6', 0, '2019-10-10 18:16:08');
74
75-- authorities
76insert into authorities (user_id, username, authority) VALUES (0, 'admin', 'ROLE_ADMIN');
77insert into authorities (user_id, username, authority) VALUES (1, 'user', 'ROLE_USER');
78insert into authorities (user_id, username, authority) VALUES (2, 'user2', 'ROLE_USER');
79insert into authorities (user_id, username, authority) VALUES (3, 'user3', 'ROLE_USER');
80
81-- places
82insert into places (name, large_description, small_description, address, user_id) VALUES ('Sea Hotel', 'Lorem ipsum dolor sit amet', 'Lorem ipsum', 'Random Road 32', 2);
83insert into places (name, large_description, small_description, address, user_id) VALUES ('Tower Hotel', 'Lorem ipsum dolor sit amet', 'Lorem ipsum', 'Random Road 16', 2);
84insert into places (name, large_description, small_description, address, user_id) VALUES ('Downtown Hotel', 'Lorem ipsum dolor sit amet', 'Lorem ipsum', 'Random Road 79', 3);
85
86insert into place_urls (place_id, url) VALUES (1, "sea-food-restaurant");
87insert into place_urls (place_id, url) VALUES (2, "tower-restaurant");
88insert into place_urls (place_id, url) VALUES (3, "downtown-chinese");
89
90-- Bookings
91insert into bookings (place_id, name, phonenumber, reservation_date, receipt_number) VALUES (1, "Matti Näsä", "0403934577", "2019-10-20", "5266894187637345544959825");
92insert into bookings (place_id, name, phonenumber, reservation_date, receipt_number) VALUES (2, "Jaakko Parantainen", "0501215281", "2019-10-04", "5466894787637345544959825");
93insert into bookings (place_id, name, phonenumber, reservation_date, receipt_number) VALUES (2, "Iso Pebe", "0505136369", "2019-10-11", "5236894787617345544959825");
94
95SET FOREIGN_KEY_CHECKS=1;