This repository has been archived by the owner on Apr 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
scripts.php
59 lines (51 loc) · 2.45 KB
/
scripts.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
<?php
return [
/*
* Installation hook.
*/
'install' => function ($app) {
$util = $app['db']->getUtility();
if ($util->tableExists('@galleries') === false) {
$util->createTable('@galleries', 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('title', 'string', ['length' => 255]);
$table->addColumn('date', 'datetime');
$table->addColumn('slug', 'string', ['length' => 255]);
$table->addColumn('description', 'text', ['notnull' => false]);
$table->addColumn('photograph', 'string', ['length' => 255, 'notnull' => false]);
$table->addColumn('status', 'smallint');
$table->addColumn('data', 'json_array', ['notnull' => false]);
$table->addColumn('roles', 'simple_array', ['notnull' => false]);
$table->addColumn('modified', 'datetime');
$table->setPrimaryKey(['id']);
});
}
if ($util->tableExists('@images') === false) {
$util->createTable('@images', function ($table) {
$table->addColumn('id', 'integer', ['unsigned' => true, 'length' => 10, 'autoincrement' => true]);
$table->addColumn('gallery_id', 'integer', ['unsigned' => true, 'length' => 10]);
$table->addColumn('user_id', 'integer', ['unsigned' => true, 'length' => 10, 'default' => 0]);
$table->addColumn('title', 'string', ['notnull' => false, 'length' => 255]);
$table->addColumn('filename', 'string', ['length' => 255]);
$table->addColumn('sort_order', 'integer', ['notnull' => false, 'length' => 10]);
$table->addColumn('data', 'json_array', ['notnull' => false]);
$table->addColumn('modified', 'datetime');
$table->setPrimaryKey(['id']);
});
}
},
/*
* Uninstall hook
*/
'uninstall' => function ($app) {
$app['config']->remove('gallery');
$util = $app['db']->getUtility();
if ($util->tableExists('@galleries')) {
$util->dropTable('@galleries');
}
if ($util->tableExists('@images')) {
$util->dropTable('@images');
}
},
];