File: 1_wicked_base_tables.php

package info (click to toggle)
php-horde-wicked 2.0.1-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,528 kB
  • ctags: 1,236
  • sloc: php: 5,386; xml: 1,027; makefile: 10; sh: 3
file content (96 lines) | stat: -rw-r--r-- 4,520 bytes parent folder | download
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
<?php
/**
 * Create Wicked base tables (as of Wicked 1.x).
 *
 * Copyright 2010-2013 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.horde.org/licenses/gpl.
 *
 * @author   Chuck Hagenbuch <chuck@horde.org>
 * @category Horde
 * @license  http://www.horde.org/licenses/gpl GPL
 * @package  Wicked
 */
class WickedBaseTables extends Horde_Db_Migration_Base
{
    /**
     * Upgrade.
     */
    public function up()
    {
        $tableList = $this->tables();

        if (!in_array('wicked_pages', $tableList)) {
            $t = $this->createTable('wicked_pages', array('autoincrementKey' => false));
            $t->column('page_id', 'integer', array('null' => false));
            $t->column('page_name', 'string', array('limit' => 100, 'null' => false));
            $t->column('page_text', 'text');
            $t->column('page_hits', 'integer', array('default' => 0));
            $t->column('page_majorversion', 'integer', array('null' => false));
            $t->column('page_minorversion', 'integer', array('null' => false));
            $t->column('version_created', 'integer', array('null' => false));
            $t->column('change_author', 'string');
            $t->column('change_log', 'text');
            $t->primaryKey(array('page_id'));
            $t->end();

            $this->addIndex('wicked_pages', array('page_name'), array('unique' => true));
        }

        if (!in_array('wicked_history', $tableList)) {
            $t = $this->createTable('wicked_history', array('autoincrementKey' => false));
            $t->column('page_id', 'integer', array('null' => false));
            $t->column('page_name', 'string', array('limit' => 100, 'null' => false));
            $t->column('page_text', 'text');
            $t->column('page_majorversion', 'integer', array('null' => false));
            $t->column('page_minorversion', 'integer', array('null' => false));
            $t->column('version_created', 'integer', array('null' => false));
            $t->column('change_author', 'string');
            $t->column('change_log', 'text');
            $t->primaryKey(array('page_id', 'page_majorversion', 'page_minorversion'));
            $t->end();
            $this->addIndex('wicked_history', array('page_name'));
            $this->addIndex('wicked_history', array('page_majorversion', 'page_minorversion'));
        }

        if (!in_array('wicked_attachments', $tableList)) {
            $t = $this->createTable('wicked_attachments', array('autoincrementKey' => false));
            $t->column('page_id', 'integer', array('null' => false));
            $t->column('attachment_name', 'string', array('limit' => 100, 'null' => false));
            $t->column('attachment_hits', 'integer', array('default' => 0));
            $t->column('attachment_majorversion', 'integer', array('null' => false));
            $t->column('attachment_minorversion', 'integer', array('null' => false));
            $t->column('attachment_created', 'integer', array('null' => false));
            $t->column('change_author', 'string');
            $t->column('change_log', 'text');
            $t->primaryKey(array('page_id', 'attachment_name'));
            $t->end();
        }

        if (!in_array('wicked_attachment_history', $tableList)) {
            $t = $this->createTable('wicked_attachment_history', array('autoincrementKey' => false));
            $t->column('page_id', 'integer', array('null' => false));
            $t->column('attachment_name', 'string', array('limit' => 100, 'null' => false));
            $t->column('attachment_majorversion', 'integer', array('null' => false));
            $t->column('attachment_minorversion', 'integer', array('null' => false));
            $t->column('attachment_created', 'integer', array('null' => false));
            $t->column('change_author', 'string');
            $t->column('change_log', 'text');
            $t->primaryKey(array('page_id', 'attachment_name', 'attachment_majorversion', 'attachment_minorversion'));
            $t->end();
            $this->addIndex('wicked_attachment_history', array('attachment_majorversion', 'attachment_minorversion'));
        }
    }

    /**
     * Downgrade.
     */
    public function down()
    {
        $this->dropTable('wicked_pages');
        $this->dropTable('wicked_history');
        $this->dropTable('wicked_attachments');
        $this->dropTable('wicked_attachment_history');
    }
}