-
Notifications
You must be signed in to change notification settings - Fork 18
/
scripts.php
80 lines (64 loc) · 2.71 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
return [
'install' => function ($app) {
$util = $app['db']->getUtility();
if ($util->tableExists('@formmaker_field') === false) {
$util->createTable('@formmaker_field', function ($table) {
$table->addColumn('id', 'integer', ['unsigned' => true, 'length' => 10, 'autoincrement' => true]);
$table->addColumn('form_id', 'integer', ['unsigned' => true, 'length' => 10]);
$table->addColumn('priority', 'integer', ['default' => 0]);
$table->addColumn('type', 'string', ['length' => 255]);
$table->addColumn('label', 'string', ['length' => 255]);
$table->addColumn('slug', 'string', ['length' => 255]);
$table->addColumn('options', 'json_array', ['notnull' => false]);
$table->addColumn('roles', 'simple_array', ['notnull' => false]);
$table->addColumn('data', 'json_array', ['notnull' => false]);
$table->setPrimaryKey(['id']);
$table->addIndex(['form_id'], 'FORMMAKER_FIELD_FORMID');
});
}
if ($util->tableExists('@formmaker_form') === false) {
$util->createTable('@formmaker_form', function ($table) {
$table->addColumn('id', 'integer', ['unsigned' => true, 'length' => 10, 'autoincrement' => true]);
$table->addColumn('status', 'smallint');
$table->addColumn('title', 'string', ['length' => 255]);
$table->addColumn('slug', 'string', ['length' => 255]);
$table->addColumn('data', 'json_array', ['notnull' => false]);
$table->setPrimaryKey(['id']);
});
}
if ($util->tableExists('@formmaker_submission') === false) {
$util->createTable('@formmaker_submission', function ($table) {
$table->addColumn('id', 'integer', ['unsigned' => true, 'length' => 10, 'autoincrement' => true]);
$table->addColumn('status', 'smallint');
$table->addColumn('form_id', 'integer', ['unsigned' => true, 'length' => 10]);
$table->addColumn('email', 'string', ['length' => 255, 'notnull' => false]);
$table->addColumn('ip', 'string', ['length' => 255]);
$table->addColumn('created', 'datetime');
$table->addColumn('data', 'json_array', ['notnull' => false]);
$table->setPrimaryKey(['id']);
});
}
},
'uninstall' => function ($app) {
$util = $app['db']->getUtility();
if ($util->tableExists('@formmaker_field')) {
$util->dropTable('@formmaker_field');
}
if ($util->tableExists('@formmaker_form')) {
$util->dropTable('@formmaker_form');
}
if ($util->tableExists('@formmaker_submission')) {
$util->dropTable('@formmaker_submission');
}
// remove the config
$app['config']->remove('bixie/formmaker');
},
'updates' => [
'1.1.0' => function ($app) {
//convert config to new module name
$app['config']->set('bixie/formmaker', $app->config('formmaker')->toArray());
$app['config']->remove('formmaker');
}
]
];