-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdates.php
126 lines (111 loc) · 2.41 KB
/
updates.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
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
<?php
namespace Icybee\Modules\Users;
use ICanBoogie\Updater\AssertionFailed;
use ICanBoogie\Updater\Update;
/**
* - Rename table `user_users` as `users`.
*
* @module users
*/
class Update20120101 extends Update
{
public function update_table_users()
{
$db = $this->app->db;
if (!$db->table_exists('user_users'))
{
throw new AssertionFailed('assert_table_exists', 'user_users');
}
if ($db->table_exists('users'))
{
throw new AssertionFailed('assert_not_table_exists', 'users');
}
$db("RENAME TABLE `{prefix}user_users` TO `users`");
}
public function update_constructor_type()
{
$db = $this->app->db;
$db("UPDATE `{prefix}users` SET constructor = 'users' WHERE constructor = 'user.users'");
}
}
/**
* - Rename `password` column as `password_hash`.
*
* @module users
*/
class Update20130101 extends Update
{
public function update_column_password_hash()
{
$this->module->model
->assert_has_column('password')
->rename_column('password', 'password_hash');
}
}
/**
* - Alter the column `password_hash` to suit the requirements of the Password API.
* - Rename the column `created` as `created_at`.
*
* @module users
*/
class Update20131021 extends Update
{
public function update_column_password_hash()
{
$this->module->model
->assert_has_column('password_hash')
->assert_not_column_has_size('password_hash', 255)
->alter_column('password_hash');
}
public function update_column_created()
{
$this->module->model
->assert_has_column('created')
->rename_column('created', 'created_at');
}
}
/**
* @module users
*/
class Update20131022 extends Update
{
/**
* Rename the column `display` as `name_as`.
*/
public function update_column_display()
{
$this->module->model
->assert_has_column('display')
->rename_column('display', 'name_as');
}
/**
* Create column `nickname`.
*/
public function update_column_nickname()
{
$this->module->model
->assert_not_has_column('nickname')
->create_column('nickname');
}
/**
* Rename column `lastconnection` as `logged_at`.
*/
public function update_column_lastconnection()
{
$this->module->model
->assert_has_column('lastconnection')
->rename_column('lastconnection', 'logged_at');
}
}
/**
* @module users
*/
class Update20150922 extends Update
{
public function update_column_siteid()
{
$this->module->models['has_many_sites']
->assert_has_column('siteid')
->rename_column('siteid', 'site_id');
}
}