-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.php
More file actions
executable file
·103 lines (93 loc) · 5.02 KB
/
scripts.php
File metadata and controls
executable file
·103 lines (93 loc) · 5.02 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
<?php
return [
'install' => function ($app) {
$util = $app['db']->getUtility();
if ($util->tableExists('@dpnblog_post') === false) {
$util->createTable('@dpnblog_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('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');
$table->addColumn('excerpt', 'text' , ['notnull' => false]);
$table->addColumn('comment_status', 'boolean', ['default' => false]);
$table->addColumn('comment_count', 'integer', ['default' => 0]);
$table->addColumn('data', 'json_array', ['notnull' => false]);
$table->addColumn('roles', 'simple_array', ['notnull' => false]);
$table->addColumn('category_id', 'integer', ['notnull' => false]);
$table->addColumn('tags', '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('@dpnblog_category') === false){
$util->createTable('@dpnblog_category' , function($table) {
$table->addColumn('id', 'integer', ['unsigned' => true, 'length' => 10, 'autoincrement' => true]);
$table->addColumn('title', 'string', ['length' => 255]);
$table->addColumn('slug', 'string', ['length' => 255]);
$table->addColumn('status', 'string', ['length' => 255]);
$table->addColumn('date', 'datetime', ['notnull' => false]);
$table->addColumn('data', 'json_array', ['notnull' => false]);
$table->addColumn('sub_category', 'simple_array', ['notnull' => false]);
$table->setPrimaryKey(['id']);
});
}
if ($util->tableExists('@dpnblog_comment') === false) {
$util->createTable('@dpnblog_comment', function ($table) {
$table->addColumn('id', 'integer', ['unsigned' => true, 'length' => 10, 'autoincrement' => true]);
$table->addColumn('parent_id', 'integer', ['unsigned' => true, 'length' => 10]);
$table->addColumn('post_id', 'integer', ['unsigned' => true, 'length' => 10]);
$table->addColumn('user_id', 'string', ['length' => 255]);
$table->addColumn('author', 'string', ['length' => 255]);
$table->addColumn('email', 'string', ['length' => 255]);
$table->addColumn('url', 'string', ['length' => 255, 'notnull' => false]);
$table->addColumn('ip', 'string', ['length' => 255]);
$table->addColumn('created', 'datetime');
$table->addColumn('content', 'text');
$table->addColumn('status', 'smallint');
$table->setPrimaryKey(['id']);
$table->addIndex(['author'], '@BLOG_COMMENT_AUTHOR');
$table->addIndex(['created'], '@BLOG_COMMENT_CREATED');
$table->addIndex(['status'], '@BLOG_COMMENT_STATUS');
$table->addIndex(['post_id'], '@BLOG_COMMENT_POST_ID');
$table->addIndex(['post_id', 'status'], '@BLOG_COMMENT_POST_ID_STATUS');
});
}
if ($util->tableExists('@dpnblog_like') == false) {
$util->createTable('@dpnblog_like' , function($table){
$table->addColumn('id', 'integer', ['unsigned' => true, 'length' => 10, 'autoincrement' => true]);
$table->addColumn('user_id' , 'integer' , ['notnull' => false]);
$table->addColumn('like_id' , 'integer' , ['notnull' => false]);
$table->addColumn('like_sy' , 'string' , ['default' => 'post']);
$table->addColumn('date', 'datetime', ['notnull' => false]);
$table->addColumn('data', 'json_array', ['notnull' => false]);
$table->setPrimaryKey(['id']);
});
}
},
'uninstall' => function ($app) {
$util = $app['db']->getUtility();
if ($util->tableExists('@dpnblog_post')) {
$util->dropTable('@dpnblog_post');
}
if ($util->tableExists('@dpnblog_comment')) {
$util->dropTable('@dpnblog_comment');
}
if ($util->tableExists('@dpnblog_category')) {
$util->dropTable('@dpnblog_category');
}
if ($util->tableExists('@dpnblog_like')) {
$util->dropTable('@dpnblog_like');
}
},
'enable' => function ($app) {},
'disable' => function ($app) {},
'updates' => []
];
?>