Skip to content

Commit

Permalink
fix: 增加数据库脚本是否强制升级参数
Browse files Browse the repository at this point in the history
  • Loading branch information
zoujingli committed Oct 15, 2024
1 parent b97a453 commit 55aa119
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions plugin/think-library/src/extend/PhinxExtend.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,19 @@ private static function write1menu(array $menu, int $ppid = 0): int
* @param \Phinx\Db\Table $table
* @param array $fields 字段配置
* @param array $indexs 索引配置
* @param boolean $force 强制更新
* @return \Phinx\Db\Table
*/
public static function upgrade(Table $table, array $fields, array $indexs = []): Table
public static function upgrade(Table $table, array $fields, array $indexs = [], bool $force = false): Table
{
[$_exists, $_fields] = [[], array_column($fields, 0)];
if ($isExists = $table->exists()) {
// 数据表存在且不强制时退出操作
if (empty($force)) return $table;
foreach ($table->getColumns() as $column) {
$_exists[] = $name = $column->getName();
if (!in_array($name, $_fields)) {
// @todo 暂时不删除字段
// @todo 为保证数据安全暂不删字段
// $table->removeColumn($name);
// $table->hasIndex($name) || $table->removeIndex($name);
}
Expand Down

0 comments on commit 55aa119

Please sign in to comment.