Skip to content

Commit

Permalink
Merge pull request #44 from php-casbin/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
leeqvip authored Oct 17, 2023
2 parents 1ab1d35 + 405ed65 commit e9af573
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ jobs:
matrix:
include:
# ThinkPHP 6.*
- php: 7.1
thinkphp: 6.*
- php: 7.2
thinkphp: 6.*
- php: 7.4
Expand All @@ -37,6 +35,8 @@ jobs:
thinkphp: 8.*
- php: 8.1
thinkphp: 8.*
- php: 8.2
thinkphp: 8.*

name: ThinkPHP${{ matrix.thinkphp }}-PHP${{ matrix.php }}

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"require": {
"casbin/casbin": "~3.0",
"topthink/framework": "~6.0|~8.0",
"topthink/think-migration": "^3.0.6",
"topthink/think-migration": "^3.1.0",
"casbin/psr3-bridge": "^1.1"
},
"require-dev": {
Expand Down
18 changes: 12 additions & 6 deletions database/migrations/20181113071924_create_rules_table.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use think\migration\Migrator;
use Phinx\Config\Config;
use Phinx\Db\Adapter\AdapterFactory;

class CreateRulesTable extends Migrator
Expand All @@ -10,17 +11,19 @@ class CreateRulesTable extends Migrator
*
* @return void
*/
protected function init()
public function init()
{
$options = $this->getDbConfig();

$adapter = AdapterFactory::instance()->getAdapter($options['adapter'], $options);

if ($adapter->hasOption('table_prefix') || $adapter->hasOption('table_suffix')) {
$adapter = AdapterFactory::instance()->getWrapper('prefix', $adapter);
}

$this->setAdapter( $adapter);
$adapter->connect();

$this->setAdapter($adapter);
}

/**
Expand All @@ -43,6 +46,7 @@ protected function getDbConfig(): array
'pass' => $config['password'],
'port' => $config['hostport'],
'charset' => $config['charset'],
'suffix' => $config['suffix'] ?? '',
'table_prefix' => $config['prefix'],
];
} else {
Expand All @@ -54,13 +58,15 @@ protected function getDbConfig(): array
'pass' => explode(',', $config['password'])[0],
'port' => explode(',', $config['hostport'])[0],
'charset' => explode(',', $config['charset'])[0],
'suffix' => explode(',', $config['suffix'] ?? '')[0],
'table_prefix' => explode(',', $config['prefix'])[0],
];
}

$table = config('database.migration_table', 'migrations');

$dbConfig['default_migration_table'] = $dbConfig['table_prefix'] . $table;
$dbConfig['migration_table'] = $dbConfig['table_prefix'] . $table;
$dbConfig['version_order'] = Config::VERSION_ORDER_CREATION_TIME;

return $dbConfig;
}
Expand Down Expand Up @@ -104,6 +110,6 @@ public function down()
{
$default = config('tauthz.default');
$table = $this->table(config('tauthz.enforcers.'.$default.'.database.rules_name'));
$table->drop();
$table->drop()->save();
}
}

0 comments on commit e9af573

Please sign in to comment.