-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInfestMySQLCreator.sql
executable file
·152 lines (129 loc) · 4.83 KB
/
InfestMySQLCreator.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
-- MySQL Script generated by MySQL Workbench
-- Mon Apr 10 19:32:14 2017
-- Model: New Model Version: 1.0
-- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
-- -----------------------------------------------------
-- Schema infest
-- -----------------------------------------------------
DROP SCHEMA IF EXISTS `infest` ;
-- -----------------------------------------------------
-- Schema infest
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `infest` DEFAULT CHARACTER SET utf8 ;
USE `infest` ;
-- -----------------------------------------------------
-- Table `infest`.`tables`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `infest`.`tables` ;
CREATE TABLE IF NOT EXISTS `infest`.`tables` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
`description` VARCHAR(255) NOT NULL,
`status` INT(2) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `id_UNIQUE` (`id` ASC),
INDEX `idx_table` (`id` ASC))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `infest`.`carts`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `infest`.`carts` ;
CREATE TABLE IF NOT EXISTS `infest`.`carts` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`idtable` INT(10) UNSIGNED NOT NULL,
`note` VARCHAR(255) NOT NULL,
`date` DATE NOT NULL,
`time` TIME NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `id_UNIQUE` (`id` ASC),
INDEX `idx_cart` (`id` ASC),
INDEX `foreign_idtable_idx` (`idtable` ASC),
CONSTRAINT `foreign_idtable`
FOREIGN KEY (`idtable`)
REFERENCES `infest`.`tables` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `infest`.`features`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `infest`.`features` ;
CREATE TABLE IF NOT EXISTS `infest`.`features` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
`description` VARCHAR(255) NOT NULL,
`status` INT(1) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `id_UNIQUE` (`id` ASC),
INDEX `idx_feature` (`id` ASC))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Inserting data for table `infest`.`features`
-- -----------------------------------------------------
INSERT INTO `features` VALUES (1,'MAINTENANCE_MODE','',0);
INSERT INTO `features` VALUES (2,'CURRENCY','GBP',0);
INSERT INTO `features` VALUES (3,'OPERATOR_GENERATE_REPORT','',0);
INSERT INTO `features` VALUES (4,'CUSTOMER_PRINT_BILL','',0);
INSERT INTO `features` VALUES (5,'CUSTOMER_SHOW_DURATION','',0);
INSERT INTO `features` VALUES (6,'CUSTOMER_SHOW_IMAGE','',0);
-- -----------------------------------------------------
-- Table `infest`.`menus`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `infest`.`menus` ;
CREATE TABLE IF NOT EXISTS `infest`.`menus` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
`description` VARCHAR(255) NOT NULL,
`status` INT(1) NOT NULL,
`status_date` DATE NOT NULL,
`type` INT(1) NOT NULL,
`price` INT(10) NOT NULL,
`stock` INT(10) NOT NULL,
`duration` TIME NOT NULL,
`image` MEDIUMBLOB,
PRIMARY KEY (`id`),
UNIQUE INDEX `id_UNIQUE` (`id` ASC),
INDEX `idx_menu` (`id` ASC))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
-- -----------------------------------------------------
-- Table `infest`.`orders`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `infest`.`orders` ;
CREATE TABLE IF NOT EXISTS `infest`.`orders` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`idcart` INT(10) UNSIGNED NOT NULL,
`idmenu` INT(10) UNSIGNED NOT NULL,
`total` INT(10) UNSIGNED NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `id_UNIQUE` (`id` ASC),
INDEX `idx_order` (`id` ASC),
INDEX `foreign_idmenu_idx` (`idcart` ASC),
INDEX `foreign_idmenu_idx1` (`idmenu` ASC),
CONSTRAINT `foreign_idcart`
FOREIGN KEY (`idcart`)
REFERENCES `infest`.`carts` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `foreign_idmenu`
FOREIGN KEY (`idmenu`)
REFERENCES `infest`.`menus` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8;
SET SQL_MODE = '';
GRANT USAGE ON *.* TO infest;
DROP USER infest;
SET SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
CREATE USER 'infest' IDENTIFIED BY 'Yogyakarta*1949#';
GRANT ALL ON `infest`.* TO 'infest';
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;