Odyssey
tools
cumanage
db
migrations
2019102300_removeGroupnameConstraint.php
1
<?php
2
/**
3
* Notes:
4
* 1. Anything complicated needs to be done with SQL.
5
* 2. Always have a check to know if the migration needs to occur (up or down).
6
* 3. Use up() and down(), not change(), because of the SQL
7
*/
8
use Phinx\Migration\AbstractMigration;
9
10
class
RemoveGroupnameConstraint
extends
AbstractMigration {
11
public
function
up() {
12
$sql =
"SELECT relname
13
FROM pg_class c
14
INNER JOIN pg_namespace n ON n.oid = c.relnamespace
15
INNER JOIN cuadmin a on c.relname = 'idx_' || coalesce(lower(a.cu), '') || '_group_name'"
;
16
17
$indices = $this->fetchAll($sql);
18
foreach
($indices as $index) {
19
$sql =
"DROP INDEX "
. $index[
"relname"
];
20
$this->query($sql);
21
}
22
}
23
24
public
function
down() {
25
}
26
}
RemoveGroupnameConstraint
Definition:
2019102300_removeGroupnameConstraint.php:10
Generated by
1.8.15