-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdump.sql
More file actions
69 lines (56 loc) · 1.97 KB
/
dump.sql
File metadata and controls
69 lines (56 loc) · 1.97 KB
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
-- CREATE SCHEMA `basiccrm` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
-- table for subscription
CREATE TABLE `subscriptions` (
`id` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(250) NULL ,
PRIMARY KEY (`id`) );
-- table for companies
CREATE TABLE `companies` (
`id` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(250) NULL ,
`subscription_id` INT NULL ,
`is_activated` TINYINT(1) NULL ,
PRIMARY KEY (`id`) ,
INDEX `company_subscription` (`subscription_id` ASC) ,
CONSTRAINT `company_subscription`
FOREIGN KEY (`subscription_id` )
REFERENCES `subscriptions` (`id` )
ON DELETE CASCADE
ON UPDATE CASCADE);
-- table for users
CREATE TABLE `users` (
`id` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR(250) NULL DEFAULT '' ,
`email` VARCHAR(250) NULL ,
`password_hash` VARCHAR(40) NULL ,
`is_admin` TINYINT(1) NULL ,
`company_id` INT NULL ,
PRIMARY KEY (`id`) ,
INDEX `user_company` (`company_id` ASC) ,
CONSTRAINT `user_company`
FOREIGN KEY (`company_id` )
REFERENCES `companies` (`id` )
ON DELETE CASCADE
ON UPDATE CASCADE);
-- adding sample subscriptions manually
INSERT INTO `subscriptions` (`id`, `name`) VALUES (1, 'Standard');
INSERT INTO `subscriptions` (`id`, `name`) VALUES (2, 'Pro');
-- table for sessions
CREATE TABLE `sessions` (
`id` VARCHAR(32) NOT NULL ,
`modified` TIMESTAMP NULL ,
`user_id` INT(11) NULL ,
PRIMARY KEY (`id`) ,
UNIQUE INDEX `id_UNIQUE` (`id` ASC) ,
INDEX `session_user` (`user_id` ASC) ,
CONSTRAINT `session_user`
FOREIGN KEY (`user_id` )
REFERENCES `users` (`id` )
ON DELETE CASCADE
ON UPDATE CASCADE);
-- adding subscriptions basic functionality
ALTER TABLE `subscriptions`
ADD COLUMN `users_limit` INT(11) NULL AFTER `name` ,
ADD COLUMN `clients_limit` INT(11) NULL AFTER `users_limit` ;
UPDATE `subscriptions` SET `users_limit`=3, `clients_limit`=1000 WHERE `id`='1';
UPDATE `subscriptions` SET `users_limit`=30, `clients_limit`=30000 WHERE `id`='2';