7 use Phinx\Migration\AbstractMigration;
18 $cuList = $this->fetchAll(
'SELECT cu FROM cuadmin');
20 for ( $i = 0; $i < count( $cuList ); $i++ ) {
21 $cu = strtolower( trim( $cuList[$i][
"cu"] ) );
25 "achtemplate" => array(
"title"=>
"group_idx",
"cols"=>
"tmpl_id, group_id"),
26 "extkey" => array(
"title"=>
"provider_idx",
"cols"=>
"providermode, accountnumber, id"),
27 "transhdr" => array(
"title"=>
"feature_idx",
"cols"=>
"id, feature_code"),
28 "transdtl" => array(
"title"=>
"transhdr_idx",
"cols"=>
"transhdr_id"),
29 "userlogins" => array(
"title"=>
"user_idx",
"cols"=>
"user_id, user_name, hcucode")
32 foreach ($tableNames as $table => $index) {
33 $tableName = $cu . $table;
34 $tableExists = $this->hasTable( $tableName );
35 $indexName = $cu . $table .
"_" . $index[
'title'];
36 $indexColumns = $index[
'cols'];
40 SELECT COUNT(*) FROM pg_class pgc 41 WHERE pgc.relname = '{$indexName}' 42 AND pgc.relkind = 'i'";
44 $idxCount = $this->fetchAll($sql);
45 $idxExists = intval($idxCount[0][
'count']);
47 if ($tableExists && $idxExists == 0) {
48 $sql =
"CREATE INDEX {$indexName} ON {$tableName} USING btree ($indexColumns)";
49 $sqlRs = $this->query($sql);
60 public function down()
64 $cuList = $this->fetchAll(
'SELECT cu FROM cuadmin');
66 for ( $i = 0; $i < count( $cuList ); $i++ ) {
67 $cu = strtolower( trim( $cuList[$i][
"cu"] ) );
71 "achtemplate" => array(
"title"=>
"group_idx",
"cols"=>
"tmpl_id, group_id"),
72 "extkey" => array(
"title"=>
"provider_idx",
"cols"=>
"providermode, accountnumber, id"),
73 "transhdr" => array(
"title"=>
"feature_idx",
"cols"=>
"id, feature_code"),
74 "transdtl" => array(
"title"=>
"transhdr_idx",
"cols"=>
"transhdr_id"),
75 "userlogins" => array(
"title"=>
"user_idx",
"cols"=>
"user_id, user_name, hcucode")
78 foreach ($tableNames as $table => $index) {
79 $tableName = $cu . $table;
80 $tableExists = $this->hasTable( $tableName );
81 $indexName = $cu . $table .
"_" . $index[
'title'];
82 $indexColumns = $index[
'cols'];
86 SELECT COUNT(*) FROM pg_class pgc 87 WHERE pgc.relname = '{$indexName}' 88 AND pgc.relkind = 'i'";
90 $idxCount = $this->fetchAll($sql);
91 $idxExists = intval($idxCount[0][
'count']);
93 if ($tableExists && $idxExists > 0) {
94 $sql =
"DROP INDEX {$indexName}";
95 $sqlRs = $this->query($sql);