-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.php
77 lines (39 loc) · 1.34 KB
/
schema.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
68
69
70
71
72
73
74
75
76
77
<?php
require 'config/init.php';
$schema =new Schema();
$query=array(
"users"=>"CREATE TABLE IF NOT EXISTS users(
id int not null AUTO_INCREMENT PRIMARY KEY,
full_name varchar(50),
email varchar(150) not null,
password text not null,
role enum('Admin','Customer','Vendor') default 'Customer',
activate_token text,
password_reset_token text,
session_token text,
status enum('Active','Inactive')default 'Active',
added_date datetime default CURRENT_TIMESTAMP,
updated_date datetime ON UPDATE CURRENT_TIMESTAMP
) ",
"user_unique"=>"ALTER TABLE users ADD UNIQUE(email)",
'alter_user'=>"ALTER TABLE `users` ADD `last_login` DATETIME NULL DEFAULT NULL AFTER `session_token`, ADD `last_Ip` VARCHAR(100) NULL DEFAULT NULL AFTER `last_login`",
"banners"=>"CREATE TABLE IF NOT EXISTS banners(
id int not null AUTO_INCREMENT PRIMARY KEY,
title text,
link text,
status ENUM ('Active','Inactive')default 'Active',
image varchar(200),
added_by int,
added_date datetime DEFAULT CURRENT_TIMESTAMP,
updated_date datetime ON UPDATE CURRENT_TIMESTAMP
)"
);
foreach($query as $key=>$sql){
$success=$schema->create($sql);
if($success){
echo "<em>Query ".$key." Executed successfully.</em><br>";
}else{
echo "<em> problem while executing ".$key." </em><br>";
}
}
?>