|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace DoctrineMigrations; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\DBAL\Migrations\AbstractMigration; |
|
6
|
|
|
use Doctrine\DBAL\Schema\Schema; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Auto-generated Migration: Please modify to your needs! |
|
10
|
|
|
*/ |
|
11
|
|
|
class Version20151124184644 extends AbstractMigration |
|
12
|
|
|
{ |
|
13
|
|
|
|
|
14
|
|
|
const NAME = 'dtb_authority_role'; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @param Schema $schema |
|
18
|
|
|
*/ |
|
|
|
|
|
|
19
|
|
|
public function up(Schema $schema) |
|
20
|
|
|
{ |
|
21
|
|
|
// this up() migration is auto-generated, please modify it to your needs |
|
22
|
|
|
if ($schema->hasTable(self::NAME)) { |
|
23
|
|
|
return true; |
|
24
|
|
|
} |
|
25
|
|
|
$table = $schema->createTable(self::NAME); |
|
26
|
|
|
|
|
27
|
|
|
$table->addColumn('authority_role_id', 'integer', array( |
|
28
|
|
|
'autoincrement' => true, |
|
29
|
|
|
)); |
|
30
|
|
|
$table->addColumn('authority_id', 'smallint', array('NotNull' => true)); |
|
31
|
|
|
$table->addColumn('deny_url', 'text', array('NotNull' => true)); |
|
32
|
|
|
$table->addColumn('creator_id', 'integer', array('NotNull' => true)); |
|
33
|
|
|
$table->addColumn('create_date', 'datetime', array('NotNull' => true)); |
|
34
|
|
|
$table->addColumn('update_date', 'datetime', array('NotNull' => true)); |
|
35
|
|
|
$table->setPrimaryKey(array('authority_role_id')); |
|
36
|
|
|
|
|
37
|
|
|
$targetTable = $schema->getTable('mtb_authority'); |
|
38
|
|
|
$table->addForeignKeyConstraint( |
|
39
|
|
|
$targetTable, |
|
40
|
|
|
array('authority_id'), |
|
41
|
|
|
array('id') |
|
42
|
|
|
); |
|
43
|
|
|
|
|
44
|
|
|
$targetTable = $schema->getTable('dtb_member'); |
|
45
|
|
|
$table->addForeignKeyConstraint( |
|
46
|
|
|
$targetTable, |
|
47
|
|
|
array('creator_id'), |
|
48
|
|
|
array('member_id') |
|
49
|
|
|
); |
|
50
|
|
|
|
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @param Schema $schema |
|
55
|
|
|
*/ |
|
|
|
|
|
|
56
|
|
|
public function down(Schema $schema) |
|
57
|
|
|
{ |
|
58
|
|
|
// this down() migration is auto-generated, please modify it to your needs |
|
59
|
|
|
if (!$schema->hasTable(self::NAME)) { |
|
60
|
|
|
return true; |
|
61
|
|
|
} |
|
62
|
|
|
$schema->dropTable(self::NAME); |
|
63
|
|
|
|
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|