summaryrefslogtreecommitdiffstats
path: root/migrations/20150528223137_create_policy_table.php
blob: e9898a6feef5a52ccaf9753239a7184a4611433b (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
31
32
<?php

use Phinx\Migration\AbstractMigration;

class CreatePolicyTable extends \Psecio\Gatekeeper\PhinxMigration
{
    protected $tableName = 'policies';

    /**
     * Migrate Up.
     */
    public function up()
    {
        $tokens = $this->table($this->getTableName());
        $tokens->addColumn('expression', 'string')
            ->addColumn('name', 'string')
            ->addColumn('description', 'text')
            ->addColumn('created', 'datetime')
            ->addColumn('updated', 'datetime', array('default' => null))
            ->save();

        $this->execute('create unique index policy_name on '.$this->getPrefix().'policies(name)');
    }

    /**
     * Migrate Down.
     */
    public function down()
    {
        $this->dropTable($this->getTableName());
    }
}