aboutsummaryrefslogtreecommitdiff
path: root/db/migrations/1.24_another_index_for_ex_termine.php
blob: d97f102fb95145d33e6af34c03104503f046e31a (plain)
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
<?php

class AnotherIndexForExTermine extends Migration {

  function description() {
    return 'another performance improving index for table "ex_termine"';
  }

  function up() {
    $db = DBManager::get();

    $mode = $db->getAttribute(PDO::ATTR_ERRMODE);
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);

    $db->exec("ALTER TABLE `ex_termine` ADD INDEX `autor_id` ( `autor_id` )");

    $mode = $db->setAttribute(PDO::ATTR_ERRMODE, $mode);
  }

  function down() {
    $db = DBManager::get();

    $mode = $db->getAttribute(PDO::ATTR_ERRMODE);
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);

    $db->exec("ALTER TABLE `ex_termine` DROP INDEX `autor_id`");

    $mode = $db->setAttribute(PDO::ATTR_ERRMODE, $mode);
  }
}