diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4fe3d05..ec9964c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: image: mysql:5.7 env: MYSQL_ALLOW_EMPTY_PASSWORD: yes - MYSQL_DATABASE: easyswoole-permission + MYSQL_DATABASE: easyswoole_permission ports: - 3306:3306 options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 @@ -60,6 +60,23 @@ jobs: - name: Checkout code uses: actions/checkout@v2 + - name: create casbin_rules table + run: | + sudo apt-get install -y mysql-client + mysql --host 127.0.0.1 --port 3306 -u root -p -e "USE easyswoole_permission; CREATE TABLE if not exists casbin_rules ( + id BigInt(20) unsigned NOT NULL AUTO_INCREMENT, + ptype varchar(255) DEFAULT NULL, + v0 varchar(255) DEFAULT NULL, + v1 varchar(255) DEFAULT NULL, + v2 varchar(255) DEFAULT NULL, + v3 varchar(255) DEFAULT NULL, + v4 varchar(255) DEFAULT NULL, + v5 varchar(255) DEFAULT NULL, + create_time timestamp NULL DEFAULT NULL, + update_time timestamp NULL DEFAULT NULL, + PRIMARY KEY (id) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" + - name: Setup PHP uses: shivammathur/setup-php@v2 with: diff --git a/composer.json b/composer.json index fd840cc..573e392 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,6 @@ }, "require-dev": { "easyswoole/easyswoole": "~3.3|~3.4", - "easyswoole/ddl": "^1.0", "easyswoole/phpunit": "^1.0" }, "autoload": { diff --git a/dev.php b/dev.php index 5483a09..39068dd 100644 --- a/dev.php +++ b/dev.php @@ -35,7 +35,7 @@ 'port' => 3306, 'user' => 'root', 'password' => '', - 'database' => 'easyswoole', + 'database' => 'easyswoole_permission', 'timeout' => 5, 'charset' => 'utf8mb4', ] diff --git a/tests/DatabaseAdapterTest.php b/tests/DatabaseAdapterTest.php index 1bf2db7..2a952c0 100644 --- a/tests/DatabaseAdapterTest.php +++ b/tests/DatabaseAdapterTest.php @@ -9,10 +9,6 @@ use EasySwoole\Permission\Config; use EasySwoole\ORM\Db\Connection; use EasySwoole\EasySwoole\Config as ESConfig; -use EasySwoole\DDL\Blueprint\Create\Table as CreateTable; -use EasySwoole\DDL\DDLBuilder; -use EasySwoole\DDL\Enum\Character; -use EasySwoole\DDL\Enum\Engine; class DatabaseAdapterTest extends TestCase { @@ -31,7 +27,6 @@ protected function getEnforcer() $this->initConfig(); $config = new Config(); $casbin = new Casbin($config); - $this->initTable(); $this->initDb(); return $casbin->enforcer(); } @@ -45,7 +40,7 @@ protected function initConfig() 'port' => 3306, 'user' => 'root', 'password' => '', - 'database' => 'easyswoole', + 'database' => 'easyswoole_permission', 'timeout' => 5, 'charset' => 'utf8mb4', ]; @@ -54,23 +49,6 @@ protected function initConfig() DbManager::getInstance()->addConnection(new Connection($config)); } - public function initTable() - { - DDLBuilder::create('casbin_rules', function (CreateTable $table) { - $table->setIfNotExists()->setTableComment('rule table of casbin'); - $table->setTableCharset(Character::UTF8MB4_GENERAL_CI); - $table->setTableEngine(Engine::MYISAM); - $table->int('id')->setIsUnsigned()->setIsAutoIncrement()->setIsPrimaryKey(); - $table->varchar('ptype', 255); - $table->varchar('v0', 255); - $table->varchar('v1', 255); - $table->varchar('v2', 255); - $table->varchar('v3', 255); - $table->varchar('v4', 255); - $table->varchar('v5', 255); - }); - } - public function testRemovePolicy() { $e = $this->getEnforcer();