Skip to content

Commit a242119

Browse files
authored
Merge pull request #7 from basakest/githubAction
fix: use 'Github Actions' to create casbin_rules table
2 parents f244176 + 4329b68 commit a242119

File tree

4 files changed

+20
-26
lines changed

4 files changed

+20
-26
lines changed

.github/workflows/build.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
image: mysql:5.7
1616
env:
1717
MYSQL_ALLOW_EMPTY_PASSWORD: yes
18-
MYSQL_DATABASE: easyswoole-permission
18+
MYSQL_DATABASE: easyswoole_permission
1919
ports:
2020
- 3306:3306
2121
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
@@ -60,6 +60,23 @@ jobs:
6060
- name: Checkout code
6161
uses: actions/checkout@v2
6262

63+
- name: create casbin_rules table
64+
run: |
65+
sudo apt-get install -y mysql-client
66+
mysql --host 127.0.0.1 --port 3306 -u root -p -e "USE easyswoole_permission; CREATE TABLE if not exists casbin_rules (
67+
id BigInt(20) unsigned NOT NULL AUTO_INCREMENT,
68+
ptype varchar(255) DEFAULT NULL,
69+
v0 varchar(255) DEFAULT NULL,
70+
v1 varchar(255) DEFAULT NULL,
71+
v2 varchar(255) DEFAULT NULL,
72+
v3 varchar(255) DEFAULT NULL,
73+
v4 varchar(255) DEFAULT NULL,
74+
v5 varchar(255) DEFAULT NULL,
75+
create_time timestamp NULL DEFAULT NULL,
76+
update_time timestamp NULL DEFAULT NULL,
77+
PRIMARY KEY (id)
78+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4"
79+
6380
- name: Setup PHP
6481
uses: shivammathur/setup-php@v2
6582
with:

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
},
1818
"require-dev": {
1919
"easyswoole/easyswoole": "~3.3|~3.4",
20-
"easyswoole/ddl": "^1.0",
2120
"easyswoole/phpunit": "^1.0"
2221
},
2322
"autoload": {

dev.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
'port' => 3306,
3636
'user' => 'root',
3737
'password' => '',
38-
'database' => 'easyswoole',
38+
'database' => 'easyswoole_permission',
3939
'timeout' => 5,
4040
'charset' => 'utf8mb4',
4141
]

tests/DatabaseAdapterTest.php

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
use EasySwoole\Permission\Config;
1010
use EasySwoole\ORM\Db\Connection;
1111
use EasySwoole\EasySwoole\Config as ESConfig;
12-
use EasySwoole\DDL\Blueprint\Create\Table as CreateTable;
13-
use EasySwoole\DDL\DDLBuilder;
14-
use EasySwoole\DDL\Enum\Character;
15-
use EasySwoole\DDL\Enum\Engine;
1612

1713
class DatabaseAdapterTest extends TestCase
1814
{
@@ -31,7 +27,6 @@ protected function getEnforcer()
3127
$this->initConfig();
3228
$config = new Config();
3329
$casbin = new Casbin($config);
34-
$this->initTable();
3530
$this->initDb();
3631
return $casbin->enforcer();
3732
}
@@ -45,7 +40,7 @@ protected function initConfig()
4540
'port' => 3306,
4641
'user' => 'root',
4742
'password' => '',
48-
'database' => 'easyswoole',
43+
'database' => 'easyswoole_permission',
4944
'timeout' => 5,
5045
'charset' => 'utf8mb4',
5146
];
@@ -54,23 +49,6 @@ protected function initConfig()
5449
DbManager::getInstance()->addConnection(new Connection($config));
5550
}
5651

57-
public function initTable()
58-
{
59-
DDLBuilder::create('casbin_rules', function (CreateTable $table) {
60-
$table->setIfNotExists()->setTableComment('rule table of casbin');
61-
$table->setTableCharset(Character::UTF8MB4_GENERAL_CI);
62-
$table->setTableEngine(Engine::MYISAM);
63-
$table->int('id')->setIsUnsigned()->setIsAutoIncrement()->setIsPrimaryKey();
64-
$table->varchar('ptype', 255);
65-
$table->varchar('v0', 255);
66-
$table->varchar('v1', 255);
67-
$table->varchar('v2', 255);
68-
$table->varchar('v3', 255);
69-
$table->varchar('v4', 255);
70-
$table->varchar('v5', 255);
71-
});
72-
}
73-
7452
public function testRemovePolicy()
7553
{
7654
$e = $this->getEnforcer();

0 commit comments

Comments
 (0)