File: 1_rampage_base_tables.php

package info (click to toggle)
php-horde-content 2.0.4-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 308 kB
  • ctags: 377
  • sloc: php: 1,454; xml: 474; makefile: 10; sh: 3
file content (40 lines) | stat: -rw-r--r-- 1,721 bytes parent folder | download | duplicates (4)
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
<?php
class RampageBaseTables extends Horde_Db_Migration_Base
{
    public function up()
    {
        $tableList = $this->tables();

        if (!in_array('rampage_types', $tableList)) {
            // rampage_types
            $t = $this->createTable('rampage_types', array('autoincrementKey' => 'type_id'));
            $t->column('type_name', 'string', array('limit' => 255, 'null' => false));
            $t->end();
            $this->addIndex('rampage_types', array('type_name'), array('name' => 'rampage_objects_type_name', 'unique' => true));
        }

        if (!in_array('rampage_objects', $tableList)) {
            // rampage_objects
            $t = $this->createTable('rampage_objects', array('autoincrementKey' => 'object_id'));
            $t->column('object_name', 'string',  array('limit' => 255, 'null' => false));
            $t->column('type_id',     'integer', array('null' => false, 'unsigned' => true));
            $t->end();
            $this->addIndex('rampage_objects', array('type_id', 'object_name'), array('name' => 'rampage_objects_type_object_name', 'unique' => true));
        }

        if (!in_array('rampage_users', $tableList)) {
            // rampage_users
            $t = $this->createTable('rampage_users', array('autoincrementKey' => 'user_id'));
            $t->column('user_name', 'string', array('limit' => 255, 'null' => false));
            $t->end();
            $this->addIndex('rampage_users', array('user_name'), array('name' => 'rampage_users_user_name', 'unique' => true));
        }
    }

    public function down()
    {
        $this->dropTable('rampage_types');
        $this->dropTable('rampage_objects');
        $this->dropTable('rampage_users');
    }
}