This repository was archived by the owner on Dec 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscripts.php
More file actions
112 lines (102 loc) · 5.17 KB
/
Copy pathscripts.php
File metadata and controls
112 lines (102 loc) · 5.17 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
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
<?php
use Doctrine\DBAL\Schema\Comparator;
return [
'enable' => function($app)
{
$util = $app['db']->getUtility();
if (!$util->tableExists('@blog_post')) {
$util->createTable('@blog_post', function ($table) {
$table->addColumn('id', 'integer', ['unsigned' => true, 'length' => 10, 'autoincrement' => true]);
$table->addColumn('user_id', 'integer', ['unsigned' => true, 'length' => 10, 'default' => 0]);
$table->addColumn('categories_id', 'simple_array' , ['notnull' => false]);
$table->addColumn('slug', 'string', ['length' => 255]);
$table->addColumn('title', 'string', ['length' => 255]);
$table->addColumn('status', 'smallint');
$table->addColumn('date', 'datetime', ['notnull' => false]);
$table->addColumn('modified', 'datetime');
$table->addColumn('content', 'text', ['notnull' => false]);
$table->addColumn('excerpt', 'text', ['notnull' => false]);
$table->addColumn('data', 'json', ['notnull' => false]);
$table->addColumn('roles', 'simple_array', ['notnull' => false]);
$table->setPrimaryKey(['id']);
$table->addUniqueIndex(['slug'], '@BLOG_POST_SLUG');
$table->addIndex(['title'], '@BLOG_POST_TITLE');
$table->addIndex(['user_id'], '@BLOG_POST_USER_ID');
$table->addIndex(['date'], '@BLOG_POST_DATE');
});
}
if(!$util->tableExists('@blog_categories')){
$util->createTable('@blog_categories', function($table){
$table->addColumn('id', 'integer' , ['unsigned' => true , 'length' => 10 , 'autoincrement' => true]);
$table->addColumn('title', 'string');
$table->addColumn('slug', 'string');
$table->addColumn('user_id' , 'integer');
$table->addColumn('status', 'smallint');
$table->addColumn('date', 'datetime', ['notnull' => false]);
$table->addColumn('excerpt', 'text', ['notnull' => false]);
$table->addColumn('roles', 'simple_array', ['notnull' => false]);
$table->addColumn('data', 'json', ['notnull' => false]);
$table->setPrimaryKey(['id']);
$table->addIndex(['title'] , '@BLOG_CATEGORIES_TITLE');
$table->addIndex(['slug'] , '@BLOG_CATEGORIES_SLUG');
});
}
},
'uninstall' => function($app)
{
$util = $app['db']->getUtility();
if ($util->tableExists('@blog_post')) {
$util->dropTable('@blog_post');
}
$util = $app['db']->getUtility();
if ($util->tableExists('@blog_categories')) {
$util->dropTable('@blog_categories');
}
},
'install' => function($app)
{
$util = $app['db']->getUtility();
},
'update' => [
'2.0.0' => function($app)
{
$util = $app['db']->getUtility();
if(!$util->tableExists('@blog_categories')){
$util->createTable('@blog_categories', function($table){
$table->addColumn('id', 'integer' , ['unsigned' => true , 'length' => 10 , 'autoincrement' => true]);
$table->addColumn('title', 'string');
$table->addColumn('slug', 'string');
$table->addColumn('user_id' , 'integer');
$table->addColumn('status', 'smallint');
$table->addColumn('date', 'datetime', ['notnull' => false]);
$table->addColumn('excerpt', 'text', ['notnull' => false]);
$table->addColumn('roles', 'simple_array', ['notnull' => false]);
$table->addColumn('data', 'json', ['notnull' => false]);
$table->setPrimaryKey(['id']);
$table->addIndex(['title'] , '@BLOG_CATEGORIES_TITLE');
$table->addIndex(['slug'] , '@BLOG_CATEGORIES_SLUG');
});
$app['db']->insert('@blog_categories' , [
'title' => 'Uncategorized',
'slug' => 'uncategorized',
'status' => 3,
'date' => date('Y-m-d H:i:s'),
'user_id' => $app['user']->id,
'roles' => null,
'excerpt' => "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod\ntempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,\nquis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo\nconsequat. Duis aute irure dolor in reprehenderit in voluptate velit esse\ncillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non\nproident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
]);
$app['db']->createQueryBuilder()
->from('@blog_post')
->where('categories_id IS NULL')
->update([
'categories_id' => 1
]);
}
},
'2.1.4' => function($app)
{
// to json
}
]
];
?>