Skip to content

Commit

Permalink
Update m141223_164316_init_rbac.php
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Chepurnoy committed Jan 12, 2015
1 parent f35895a commit 5aba6e7
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions migrations/m141223_164316_init_rbac.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ public function up()
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}

$this->createTable('{{%auth_rule}}', [
$this->createTable('{{%AuthRule}}', [
'name' => Schema::TYPE_STRING . '(64) NOT NULL',
'data' => Schema::TYPE_TEXT,
'created_at' => Schema::TYPE_INTEGER,
'updated_at' => Schema::TYPE_INTEGER,
'PRIMARY KEY (name)',
], $tableOptions);

$this->createTable('{{%auth_item}}', [
$this->createTable('{{%AuthItem}}', [
'name' => Schema::TYPE_STRING . '(64) NOT NULL',
'type' => Schema::TYPE_INTEGER . ' NOT NULL',
'description' => Schema::TYPE_TEXT,
Expand All @@ -30,33 +30,33 @@ public function up()
'created_at' => Schema::TYPE_INTEGER,
'updated_at' => Schema::TYPE_INTEGER,
'PRIMARY KEY (name)',
'FOREIGN KEY (rule_name) REFERENCES ' . '{{%auth_rule}}' . ' (name) ON DELETE SET NULL ON UPDATE CASCADE',
'FOREIGN KEY (rule_name) REFERENCES ' . '{{%AuthRule}}' . ' (name) ON DELETE SET NULL ON UPDATE CASCADE',
], $tableOptions);
$this->createIndex('idx-auth_item-type', '{{%auth_item}}', 'type');
$this->createIndex('idx-auth_item-type', '{{%AuthItem}}', 'type');

$this->createTable('{{%auth_item_child}}', [
$this->createTable('{{%AuthItemChild}}', [
'parent' => Schema::TYPE_STRING . '(64) NOT NULL',
'child' => Schema::TYPE_STRING . '(64) NOT NULL',
'PRIMARY KEY (parent, child)',
'FOREIGN KEY (parent) REFERENCES ' . '{{%auth_item}}' . ' (name) ON DELETE CASCADE ON UPDATE CASCADE',
'FOREIGN KEY (child) REFERENCES ' . '{{%auth_item}}' . ' (name) ON DELETE CASCADE ON UPDATE CASCADE',
'FOREIGN KEY (parent) REFERENCES ' . '{{%AuthItem}}' . ' (name) ON DELETE CASCADE ON UPDATE CASCADE',
'FOREIGN KEY (child) REFERENCES ' . '{{%AuthItem}}' . ' (name) ON DELETE CASCADE ON UPDATE CASCADE',
], $tableOptions);

$this->createTable('{{%auth_assignment}}', [
$this->createTable('{{%AuthAssignment}}', [
'item_name' => Schema::TYPE_STRING . '(64) NOT NULL',
'user_id' => Schema::TYPE_STRING . '(64) NOT NULL',
'created_at' => Schema::TYPE_INTEGER,
'PRIMARY KEY (item_name, user_id)',
'FOREIGN KEY (item_name) REFERENCES ' . '{{%auth_item}}' . ' (name) ON DELETE CASCADE ON UPDATE CASCADE',
'FOREIGN KEY (item_name) REFERENCES ' . '{{%AuthItem}}' . ' (name) ON DELETE CASCADE ON UPDATE CASCADE',
], $tableOptions);

}

public function down()
{
$this->dropTable('{{%auth_assignment}}');
$this->dropTable('{{%auth_item_child}}');
$this->dropTable('{{%auth_item}}');
$this->dropTable('{{%auth_rule}}');
$this->dropTable('{{%AuthAssignment}}');
$this->dropTable('{{%AuthItemChild}}');
$this->dropTable('{{%AuthItem}}');
$this->dropTable('{{%AuthRule}}');
}
}

0 comments on commit 5aba6e7

Please sign in to comment.