PHPackages                             a2workspace/laravel-database-patcher - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. a2workspace/laravel-database-patcher

ActiveLibrary[Database &amp; ORM](/categories/database)

a2workspace/laravel-database-patcher
====================================

一個基於專案的資料庫補丁管理工具

1.1.1(3y ago)797MITPHPPHP ^7.4|^8.0

Since Jul 24Pushed 3y ago1 watchersCompare

[ Source](https://github.com/A2Workspace/laravel-database-patcher)[ Packagist](https://packagist.org/packages/a2workspace/laravel-database-patcher)[ RSS](/packages/a2workspace-laravel-database-patcher/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

Laravel-Database-Patcher
========================

[](#laravel-database-patcher)

[ ![](https://github.com/A2Workspace/laravel-database-patcher/actions/workflows/coverage.yml/badge.svg)](https://github.com/A2Workspace/laravel-database-patcher)[ ![](https://camo.githubusercontent.com/010024d15ff9c03646725c69a7f184a5af82022c5b7bbdee3a0beb516ef905bd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f4132576f726b73706163652f6c61726176656c2d64617461626173652d706174636865722f74657374733f7374796c653d666c61742d737175617265)](https://github.com/A2Workspace/laravel-database-patcher)[ ![](https://camo.githubusercontent.com/e4221045f7a2d64af2baa7f482579f7cf55c92c0854a02403a55249b6905ed35/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f4132576f726b73706163652f6c61726176656c2d64617461626173652d706174636865722e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/gh/A2Workspace/laravel-database-patcher)[ ![](https://camo.githubusercontent.com/1527f3862fc7f0bf6fe9e92ef3760858b6eea8f84bdf5999eb0040f6f8d9f89a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f4132576f726b73706163652f6c61726176656c2d64617461626173652d706174636865723f7374796c653d666c61742d737175617265)](https://github.com/A2Workspace/laravel-database-patcher/blob/master/LICENSE)[ ![](https://camo.githubusercontent.com/fb5df0ed566e10d9a405f2413e31e1b6c81bd32f140227cf6acd3419cf21aca1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6132776f726b73706163652f6c61726176656c2d64617461626173652d706174636865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/a2workspace/laravel-database-patcher)[ ![](https://camo.githubusercontent.com/89571809a4ec90134c7e678ae6560f5218536188ae0dd6ab67cbccbb1541722c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6132776f726b73706163652f6c61726176656c2d64617461626173652d706174636865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/a2workspace/laravel-database-patcher)

一個基於專案的資料庫補丁管理工具。

[![Laravel-Database-Patcher demo animation](/.github/animation.gif)](/.github/animation.gif)

隨著專案的進行，難免需要對現有的資料表修修補補，但檔案過於複雜的 `database/migrations` 可能會產生一些問題。`a2workspace/laravel-database-patcher` 提供簡易的管理工具，讓你可以使用獨立的 `database/patches` 資料夾，來放置額外的 **遷移檔 (Migration)** 。

本套件可以解決以下問題:

- 開發者想增加某些修復用的 **遷移檔 (Migration)** ，但又不想放進 `database/migrations` 影響開發或測試的情形
- 運維人員想編寫一些資料修正的腳本，又不想影響開發或測試的情形
- 運維人員想編寫一些資料修正的腳本，並在測試機環境執行一遍，待測試過了才在正式機環境運行的情形

Installation | 安裝
-----------------

[](#installation--安裝)

執行下列命令透過 **composer** 引入到你的 **Laravel** 專案:

```
composer require a2workspace/laravel-database-patcher

```

接著使用 `vendor:publish` 命令生成 `database/patches` 資料夾:

```
php artisan vendor:publish --tag=@a2workspace/laravel-database-patcher
```

Usage | 如何使用
------------

[](#usage--如何使用)

現在你可以使用 `db:patch` [Artisan 命令](https://laravel.com/docs/9.x/artisan)來管理資料庫遷移補丁。

```
php artisan db:patch
```

該命令將會讀取 `database/patches` 下的 [Migrations 遷移檔](https://laravel.com/docs/9.x/migrations)，並列出可用選項。

### Reverting Back Patches | 還原已安裝的補丁

[](#reverting-back-patches--還原已安裝的補丁)

使用 `--revert` 或簡寫 `-r` 參數，可將已安裝的遷移檔進行 **滾回 (rollback)** 動作:

```
php artisan db:patch --revert
```

Generating Patches | 如何產生補丁檔
----------------------------

[](#generating-patches--如何產生補丁檔)

補丁與原生的 **遷移檔 (Migration)** 完全相同，你可以參考 [Generating Migrations](https://laravel.com/docs/9.x/migrations#generating-migrations) 與 [Updating Tables](https://laravel.com/docs/9.x/migrations#updating-tables) 的說明生成 **遷移檔 (Migration)** ，接著再把檔案移至 `database/patches` 資料夾內。

或直接用 `make` 命令生成:

```
php artisan make:migration --path=database/patches add_soft_deletes_to_users_table
```

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

1439d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3df1b6bbe4567dd2a69769a4902e86f1e479065d5c5cf395f8104dde6f08deb3?d=identicon)[Shishamou](/maintainers/Shishamou)

---

Top Contributors

[![Shishamou](https://avatars.githubusercontent.com/u/7775781?v=4)](https://github.com/Shishamou "Shishamou (6 commits)")

---

Tags

databaselaravelphp

### Embed Badge

![Health badge](/badges/a2workspace-laravel-database-patcher/health.svg)

```
[![Health](https://phpackages.com/badges/a2workspace-laravel-database-patcher/health.svg)](https://phpackages.com/packages/a2workspace-laravel-database-patcher)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M118](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
