Skip to content

Commit e9af573

Browse files
authored
Merge pull request #44 from php-casbin/develop
Develop
2 parents 1ab1d35 + 405ed65 commit e9af573

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

.github/workflows/default.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ jobs:
2121
matrix:
2222
include:
2323
# ThinkPHP 6.*
24-
- php: 7.1
25-
thinkphp: 6.*
2624
- php: 7.2
2725
thinkphp: 6.*
2826
- php: 7.4
@@ -37,6 +35,8 @@ jobs:
3735
thinkphp: 8.*
3836
- php: 8.1
3937
thinkphp: 8.*
38+
- php: 8.2
39+
thinkphp: 8.*
4040

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

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"require": {
2323
"casbin/casbin": "~3.0",
2424
"topthink/framework": "~6.0|~8.0",
25-
"topthink/think-migration": "^3.0.6",
25+
"topthink/think-migration": "^3.1.0",
2626
"casbin/psr3-bridge": "^1.1"
2727
},
2828
"require-dev": {

database/migrations/20181113071924_create_rules_table.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
use think\migration\Migrator;
4+
use Phinx\Config\Config;
45
use Phinx\Db\Adapter\AdapterFactory;
56

67
class CreateRulesTable extends Migrator
@@ -10,17 +11,19 @@ class CreateRulesTable extends Migrator
1011
*
1112
* @return void
1213
*/
13-
protected function init()
14+
public function init()
1415
{
1516
$options = $this->getDbConfig();
16-
17+
1718
$adapter = AdapterFactory::instance()->getAdapter($options['adapter'], $options);
18-
19+
1920
if ($adapter->hasOption('table_prefix') || $adapter->hasOption('table_suffix')) {
2021
$adapter = AdapterFactory::instance()->getWrapper('prefix', $adapter);
2122
}
2223

23-
$this->setAdapter( $adapter);
24+
$adapter->connect();
25+
26+
$this->setAdapter($adapter);
2427
}
2528

2629
/**
@@ -43,6 +46,7 @@ protected function getDbConfig(): array
4346
'pass' => $config['password'],
4447
'port' => $config['hostport'],
4548
'charset' => $config['charset'],
49+
'suffix' => $config['suffix'] ?? '',
4650
'table_prefix' => $config['prefix'],
4751
];
4852
} else {
@@ -54,13 +58,15 @@ protected function getDbConfig(): array
5458
'pass' => explode(',', $config['password'])[0],
5559
'port' => explode(',', $config['hostport'])[0],
5660
'charset' => explode(',', $config['charset'])[0],
61+
'suffix' => explode(',', $config['suffix'] ?? '')[0],
5762
'table_prefix' => explode(',', $config['prefix'])[0],
5863
];
5964
}
6065

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

63-
$dbConfig['default_migration_table'] = $dbConfig['table_prefix'] . $table;
68+
$dbConfig['migration_table'] = $dbConfig['table_prefix'] . $table;
69+
$dbConfig['version_order'] = Config::VERSION_ORDER_CREATION_TIME;
6470

6571
return $dbConfig;
6672
}
@@ -104,6 +110,6 @@ public function down()
104110
{
105111
$default = config('tauthz.default');
106112
$table = $this->table(config('tauthz.enforcers.'.$default.'.database.rules_name'));
107-
$table->drop();
113+
$table->drop()->save();
108114
}
109115
}

0 commit comments

Comments
 (0)