Skip to content

Commit 0d1672a

Browse files
committed
fix: Update think-migration to v3.1.0
1 parent 1ab1d35 commit 0d1672a

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

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)