-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb.php
executable file
·67 lines (57 loc) · 2.37 KB
/
db.php
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
<?php
$q = "ALTER TABLE user ADD full_name VARCHAR(266) NOT NULL AFTER username";
$q = "ALTER TABLE user ADD photo VARCHAR(500) NOT NULL DEFAULT '' AFTER full_name";
$q = "CREATE TABLE vehicle (
id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
model_id SMALLINT UNSIGNED NOT NULL,
frame_number VARCHAR(20) NOT NULL
)ENGINE=InnoDB DEFAULT CHARSET=utf8;";
$q = "CREATE TABLE brand (
id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL
)ENGINE=InnoDB DEFAULT CHARSET=utf8;";
$q = "CREATE TABLE model (
id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
brand_id SMALLINT UNSIGNED NOT NULL,
name VARCHAR(100) NOT NULL
)ENGINE=InnoDB DEFAULT CHARSET=utf8;";
$q = "CREATE TABLE client (
id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
full_name VARCHAR(100) NOT NULL,
phone_number VARCHAR(15) NOT NULL
)ENGINE=InnoDB DEFAULT CHARSET=utf8;";
$q = "CREATE TABLE job (
id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
client_id SMALLINT UNSIGNED NOT NULL,
vehicle_id SMALLINT UNSIGNED NOT NULL,
creator_id SMALLINT UNSIGNED NOT NULL COMMENT 'User id',
performer_id SMALLINT UNSIGNED DEFAULT 0 COMMENT 'User id',
created_at DATETIME,
status ENUM('new', 'on-the-job', 'pending', 'done','closed') DEFAULT 'new',
addition TEXT COMMENT 'Additional Information',
pay INT(1) UNSIGNED NOT NULL DEFAULT 0,
done_at DATETIME DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
$q = "ALTER TABLE job ADD done_at DATETIME DEFAULT NULL";
$q = "CREATE TABLE task (
id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
job_id SMALLINT UNSIGNED NOT NULL,
name TEXT NOT NULL,
price FLOAT DEFAULT 0,
performer_percent TINYINT DEFAULT 0
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
$q = "ALTER TABLE task ADD price FLOAT DEFAULT 0";
$q = "ALTER TABLE task ADD performer_percent TINYINT DEFAULT 0";
$q = "CREATE TABLE job_log (
id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
job_id SMALLINT UNSIGNED NOT NULL,
info VARCHAR(255) NOT NULL,
created_at DATETIME
) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
$q = "CREATE TABLE parts (
id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
job_id SMALLINT UNSIGNED NOT NULL,
name TEXT NOT NULL,
price FLOAT DEFAULT 0,
quantity SMALLINT UNSIGNED NOT NULL DEFAULT 1
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";