Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
ef4d9683
Commit
ef4d9683
authored
May 07, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed RBAC migration for SQLite
parent
905e39ed
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
28 deletions
+24
-28
m140506_102106_rbac_init.php
framework/rbac/migrations/m140506_102106_rbac_init.php
+8
-8
DbManagerTestCase.php
tests/unit/framework/rbac/DbManagerTestCase.php
+16
-20
No files found.
framework/rbac/migrations/m140506_102106_rbac_init.php
View file @
ef4d9683
...
@@ -33,8 +33,8 @@ class m140506_102106_rbac_init extends \yii\db\Migration
...
@@ -33,8 +33,8 @@ class m140506_102106_rbac_init extends \yii\db\Migration
'data'
=>
Schema
::
TYPE_TEXT
,
'data'
=>
Schema
::
TYPE_TEXT
,
'created_at'
=>
Schema
::
TYPE_INTEGER
,
'created_at'
=>
Schema
::
TYPE_INTEGER
,
'updated_at'
=>
Schema
::
TYPE_INTEGER
,
'updated_at'
=>
Schema
::
TYPE_INTEGER
,
'PRIMARY KEY (name)'
,
],
$tableOptions
);
],
$tableOptions
);
$this
->
addPrimaryKey
(
'pk-auth_rule'
,
$authManager
->
ruleTable
,
'name'
);
$this
->
createTable
(
$authManager
->
itemTable
,
[
$this
->
createTable
(
$authManager
->
itemTable
,
[
'name'
=>
Schema
::
TYPE_STRING
.
'(64) NOT NULL'
,
'name'
=>
Schema
::
TYPE_STRING
.
'(64) NOT NULL'
,
...
@@ -44,26 +44,26 @@ class m140506_102106_rbac_init extends \yii\db\Migration
...
@@ -44,26 +44,26 @@ class m140506_102106_rbac_init extends \yii\db\Migration
'data'
=>
Schema
::
TYPE_TEXT
,
'data'
=>
Schema
::
TYPE_TEXT
,
'created_at'
=>
Schema
::
TYPE_INTEGER
,
'created_at'
=>
Schema
::
TYPE_INTEGER
,
'updated_at'
=>
Schema
::
TYPE_INTEGER
,
'updated_at'
=>
Schema
::
TYPE_INTEGER
,
'PRIMARY KEY (name)'
,
'FOREIGN KEY (rule_name) REFERENCES '
.
$authManager
->
ruleTable
.
' (name) ON DELETE SET NULL ON UPDATE CASCADE'
,
],
$tableOptions
);
],
$tableOptions
);
$this
->
addPrimaryKey
(
'pk-auth_item'
,
$authManager
->
itemTable
,
'name'
);
$this
->
addForeignKey
(
'fk-auth_item-rule_name'
,
$authManager
->
itemTable
,
'rule_name'
,
$authManager
->
ruleTable
,
'name'
,
'SET NULL'
,
'CASCADE'
);
$this
->
createIndex
(
'idx-auth_item-type'
,
$authManager
->
itemTable
,
'type'
);
$this
->
createIndex
(
'idx-auth_item-type'
,
$authManager
->
itemTable
,
'type'
);
$this
->
createTable
(
$authManager
->
itemChildTable
,
[
$this
->
createTable
(
$authManager
->
itemChildTable
,
[
'parent'
=>
Schema
::
TYPE_STRING
.
'(64) NOT NULL'
,
'parent'
=>
Schema
::
TYPE_STRING
.
'(64) NOT NULL'
,
'child'
=>
Schema
::
TYPE_STRING
.
'(64) NOT NULL'
,
'child'
=>
Schema
::
TYPE_STRING
.
'(64) NOT NULL'
,
'PRIMARY KEY (parent, child)'
,
'FOREIGN KEY (parent) REFERENCES '
.
$authManager
->
itemTable
.
' (name) ON DELETE CASCADE ON UPDATE CASCADE'
,
'FOREIGN KEY (child) REFERENCES '
.
$authManager
->
itemTable
.
' (name) ON DELETE CASCADE ON UPDATE CASCADE'
,
],
$tableOptions
);
],
$tableOptions
);
$this
->
addPrimaryKey
(
'pk-auth_item_child'
,
$authManager
->
itemChildTable
,
[
'parent'
,
'child'
]);
$this
->
addForeignKey
(
'fk-auth_item_child-parent'
,
$authManager
->
itemChildTable
,
'parent'
,
$authManager
->
itemTable
,
'name'
,
'CASCADE'
,
'CASCADE'
);
$this
->
addForeignKey
(
'fk-auth_item_child-child'
,
$authManager
->
itemChildTable
,
'child'
,
$authManager
->
itemTable
,
'name'
,
'CASCADE'
,
'CASCADE'
);
$this
->
createTable
(
$authManager
->
assignmentTable
,
[
$this
->
createTable
(
$authManager
->
assignmentTable
,
[
'item_name'
=>
Schema
::
TYPE_STRING
.
'(64) NOT NULL'
,
'item_name'
=>
Schema
::
TYPE_STRING
.
'(64) NOT NULL'
,
'user_id'
=>
Schema
::
TYPE_STRING
.
'(64) NOT NULL'
,
'user_id'
=>
Schema
::
TYPE_STRING
.
'(64) NOT NULL'
,
'created_at'
=>
Schema
::
TYPE_INTEGER
,
'created_at'
=>
Schema
::
TYPE_INTEGER
,
'PRIMARY KEY (item_name, user_id)'
,
'FOREIGN KEY (item_name) REFERENCES '
.
$authManager
->
itemTable
.
' (name) ON DELETE CASCADE ON UPDATE CASCADE'
,
],
$tableOptions
);
],
$tableOptions
);
$this
->
addPrimaryKey
(
'pk-auth_assignment'
,
$authManager
->
assignmentTable
,
[
'item_name'
,
'user_id'
]);
$this
->
addForeignKey
(
'fk-auth_assignment-item_name'
,
$authManager
->
assignmentTable
,
'item_name'
,
$authManager
->
itemTable
,
'name'
,
'CASCADE'
,
'CASCADE'
);
}
}
public
function
down
()
public
function
down
()
...
...
tests/unit/framework/rbac/DbManagerTestCase.php
View file @
ef4d9683
...
@@ -77,32 +77,28 @@ abstract class DbManagerTestCase extends ManagerTestCase
...
@@ -77,32 +77,28 @@ abstract class DbManagerTestCase extends ManagerTestCase
}
}
/**
/**
* @param boolean $reset whether to clean up the test database
* @param boolean $open whether to open and populate test database
* @throws \yii\base\InvalidParamException
* @throws \yii\base\InvalidParamException
* @throws \yii\db\Exception
* @throws \yii\db\Exception
* @throws \yii\base\InvalidConfigException
* @throws \yii\base\InvalidConfigException
* @return \yii\db\Connection
* @return \yii\db\Connection
*/
*/
public
static
function
getConnection
(
$reset
=
true
,
$open
=
true
)
public
static
function
getConnection
()
{
{
if
(
!
$reset
&&
static
::
$db
)
{
if
(
static
::
$db
==
null
)
{
return
static
::
$db
;
$db
=
new
Connection
;
$db
->
dsn
=
static
::
$database
[
'dsn'
];
if
(
isset
(
static
::
$database
[
'username'
]))
{
$db
->
username
=
static
::
$database
[
'username'
];
$db
->
password
=
static
::
$database
[
'password'
];
}
if
(
isset
(
static
::
$database
[
'attributes'
]))
{
$db
->
attributes
=
static
::
$database
[
'attributes'
];
}
if
(
!
$db
->
isActive
)
{
$db
->
open
();
}
static
::
$db
=
$db
;
}
}
$db
=
new
Connection
;
return
static
::
$db
;
$db
->
dsn
=
static
::
$database
[
'dsn'
];
if
(
isset
(
static
::
$database
[
'username'
]))
{
$db
->
username
=
static
::
$database
[
'username'
];
$db
->
password
=
static
::
$database
[
'password'
];
}
if
(
isset
(
static
::
$database
[
'attributes'
]))
{
$db
->
attributes
=
static
::
$database
[
'attributes'
];
}
if
(
$open
)
{
$db
->
open
();
}
static
::
$db
=
$db
;
return
$db
;
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment