PHPackages                             orptech/laravel-migration-partition - 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. orptech/laravel-migration-partition

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

orptech/laravel-migration-partition
===================================

Laravel extensions that extends Illuminate to enable partitioned table creation within Laravel migrations.

v12.0.1(8mo ago)3426.7k↓42.9%7[2 PRs](https://github.com/orptech-com/laravel-migration-partition/pulls)MITPHPPHP ^8.2CI passing

Since Oct 6Pushed 1mo ago4 watchersCompare

[ Source](https://github.com/orptech-com/laravel-migration-partition)[ Packagist](https://packagist.org/packages/orptech/laravel-migration-partition)[ Docs](https://github.com/orptech/laravel-migration-partition)[ RSS](/packages/orptech-laravel-migration-partition/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (17)Versions (38)Used By (0)

[![](https://camo.githubusercontent.com/2517980964372c61e86022b23e1bd56d1903a8f62e8866085f5ab482354fa742/68747470733a2f2f6f7270746563682e636f6d2f6173736574732f696d616765732f6c6f676f732f6f7270746563682d6c6f676f2d77686974652e706e67)](https://orptech.com)

[![](https://camo.githubusercontent.com/e2e7c4f41a3bc71a73b3b6e7a9c802148ee71f2622cc865927c4f96be7b52fca/68747470733a2f2f726574726f636b65742e696f2f636f6d6d6f6e2f696d672f6c6f676f5f77686974652e706e67)](https://retrocket.io)

Database Partitions via Migrations for Laravel (aka Laravel Migration Partitions)
=================================================================================

[](#database-partitions-via-migrations-for-laravel-aka-laravel-migration-partitions)

This package extends Illuminate to provide partitioned table creation in migrations for PostgreSQL. Support for other DMBS's will be added soon.

[![Latest Version on Packagist](https://camo.githubusercontent.com/798c01c37c285cc873f67851bc68e2a03d70267329b5907181a9bea79d79874c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f7270746563682f6c61726176656c2d6d6967726174696f6e2d706172746974696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/orptech/laravel-migration-partition)[![Total Downloads](https://camo.githubusercontent.com/b24e1a91400644bae3a4bad81e8cfd930a55b1f0f99a4322dffae0fc6daa687f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f7270746563682f6c61726176656c2d6d6967726174696f6e2d706172746974696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/orptech/laravel-migration-partition)

ORPtech Software
----------------

[](#orptech-software)

We are ORPtech. Here at ORPtech, we pride ourselves in ensuring that clients and services have a peaceful, safe and smooth interaction. We know how difficult it is to build trust for a service, therefore we are here to help bridge the gaps within the market via our robust applications. Please contact us for further information on how our services might help your business.

Version Matching
----------------

[](#version-matching)

**Package Version****Supported**11.x.x**Laravel 11**12.x.x**Laravel 12**Installation
------------

[](#installation)

You can install the package via composer:

```
composer require orptech/laravel-migration-partition
```

DBMS Support
------------

[](#dbms-support)

- PostgreSQL

### Planned Development

[](#planned-development)

- MySQL - Looking for Contributors
- MariaDB - Looking for Contributors
- SQL Server 2017+
- SQLite 3.8.8+

Usage
-----

[](#usage)

This package currently, only supports PostgreSQL.

PostgreSQL
----------

[](#postgresql)

PostgreSQL also known as Postgres, is a free and open-source relational database management system (RDBMS) emphasizing extensibility and SQL compliance.

### Range Partitioning

[](#range-partitioning)

Instead of importing Illuminate's Schema import this package's schema:

```
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
```

Template Usage
--------------

[](#template-usage)

### Range Partition

[](#range-partition)

```
use ORPTech\MigrationPartition\Database\Schema\Blueprint;
use ORPTech\MigrationPartition\Support\Facades\Schema;

Schema::createRangePartitioned('[YourTableNameHere]', function (Blueprint $table) {
    //...
}, '[compositeKeyOne]', '[compositeKeyTwo]', '[rangePartitionKey]');
```

Enter null for `[compositeKeyOne]`, `[compositeKeyTwo]` if you don't need a primary key.

##### Creating a Range Partition for a Partitioned Table

[](#creating-a-range-partition-for-a-partitioned-table)

```
use ORPTech\MigrationPartition\Database\Schema\Blueprint;
use ORPTech\MigrationPartition\Support\Facades\Schema;

Schema::createRangePartition('[YourPartitionedTableNameHere]', function (Blueprint $table) {}, '[suffixForPartition]', '[startDate]', '[endDate]');
```

##### Attaching a Range Partition to a Partitioned Table

[](#attaching-a-range-partition-to-a-partitioned-table)

```
use ORPTech\MigrationPartition\Database\Schema\Blueprint;
use ORPTech\MigrationPartition\Support\Facades\Schema;

Schema::attachRangePartition('[YourPartitionedTableNameHere]', function (Blueprint $table) {}, '[suffixForPartition]', '[startDate]', '[endDate]');
```

### List Partition

[](#list-partition)

```
use ORPTech\MigrationPartition\Database\Schema\Blueprint;
use ORPTech\MigrationPartition\Support\Facades\Schema;

Schema::createListPartitioned('[YourTableNameHere]', function (Blueprint $table) {
    //...
}, '[compositeKeyOne]', '[compositeKeyTwo]', '[listPartitionKey]');
```

Enter null for `[compositeKeyOne]`, `[compositeKeyTwo]` if you don't need a primary key.

##### Creating a List Partition for a Partitioned Table

[](#creating-a-list-partition-for-a-partitioned-table)

```
use ORPTech\MigrationPartition\Database\Schema\Blueprint;
use ORPTech\MigrationPartition\Support\Facades\Schema;

Schema::createListPartition('[YourPartitionedTableNameHere]', function (Blueprint $table) {}, '[suffixForPartition]', '[listPartitionValue]');
```

##### Attaching a List Partition to a Partitioned Table

[](#attaching-a-list-partition-to-a-partitioned-table)

```
use ORPTech\MigrationPartition\Database\Schema\Blueprint;
use ORPTech\MigrationPartition\Support\Facades\Schema;

Schema::attachListPartition('[YourPartitionedTableNameHere]', function (Blueprint $table) {}, '[suffixForPartition]', '[listPartitionValue]');
```

### Hash Partition

[](#hash-partition)

```
use ORPTech\MigrationPartition\Database\Schema\Blueprint;
use ORPTech\MigrationPartition\Support\Facades\Schema;

Schema::createHashPartitioned('[YourTableNameHere]', function (Blueprint $table) {
    //...
}, '[compositeKeyOne]', '[compositeKeyTwo]', '[hashPartitionKey]');
```

Enter null for `[compositeKeyOne]`, `[compositeKeyTwo]` if you don't need a primary key.

##### Creating a Hash Partition for a Partitioned Table

[](#creating-a-hash-partition-for-a-partitioned-table)

```
use ORPTech\MigrationPartition\Database\Schema\Blueprint;
use ORPTech\MigrationPartition\Support\Facades\Schema;

Schema::createHashPartition('[YourPartitionedTableNameHere]', function (Blueprint $table) {}, '[suffixForPartition]', '[hashModulus]', '[hashRemainder]');
```

##### Attaching a Hash Partition to a Partitioned Table

[](#attaching-a-hash-partition-to-a-partitioned-table)

```
use ORPTech\MigrationPartition\Database\Schema\Blueprint;
use ORPTech\MigrationPartition\Support\Facades\Schema;

Schema::attachHashPartition('[YourPartitionedTableNameHere]', function (Blueprint $table) {}, '[suffixForPartition]', '[hashModulus]', '[hashRemainder]');
```

#### Removing a Partition

[](#removing-a-partition)

```
use ORPTech\MigrationPartition\Database\Schema\Blueprint;
use ORPTech\MigrationPartition\Support\Facades\Schema;

Schema::detachPartition('[YourPartitionedTableNameHere]', function (Blueprint $table) {}, '[partitionTableName]');
```

Commands
--------

[](#commands)

##### New Series of Range Partition Migrations

[](#new-series-of-range-partition-migrations)

This command will create a new series of migrations for all range partitioned tables.

```
php artisan partition:range
```

##### New Series of List Partition Migrations

[](#new-series-of-list-partition-migrations)

This command will create a new series of migrations for all list partitioned tables.

```
php artisan partition:list
```

##### New Series of Hash Partition Migrations

[](#new-series-of-hash-partition-migrations)

This command will create a new series of migrations for all hash partitioned tables.

```
php artisan partition:hash
```

##### Listing Partitions

[](#listing-partitions)

This command will list all the partitioned tables.

```
php artisan partition:partitions
```

### Important

[](#important)

- This package currently supports PostgreSQL Range Partitions.
- You shouldn't define any primary keys in your migration. The package creates a composite key while setting up the table.
- You need to create an initial partition to start using the tables. (PostgreSQL)

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [ORPtech](https://github.com/orptech-com)
- [Retrocket](https://github.com/retrocket)
- [Laravel](https://github.com/laravel)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance76

Regular maintenance activity

Popularity39

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 65.2% 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 ~57 days

Recently: every ~213 days

Total

23

Last Release

57d ago

Major Versions

v2.0.0 → v3.0.0-beta2022-10-11

v3.0.0 → v4.0.02023-02-17

v4.0.4 → v11.0.02024-06-08

v11.0.0 → v12.0.02025-05-19

v12.0.1 → v13.0.0-beta2026-03-23

PHP version history (3 changes)v1.0.0PHP ^8.1

v11.0.0PHP ^8.2

v13.0.0-betaPHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/a1fe3891cb9de906466f4c197aca348156f27932890543c96a994becf2755bf1?d=identicon)[ArdaKaraderi](/maintainers/ArdaKaraderi)

---

Top Contributors

[![ArdaKaraderi](https://avatars.githubusercontent.com/u/22325146?v=4)](https://github.com/ArdaKaraderi "ArdaKaraderi (45 commits)")[![denizgolbas](https://avatars.githubusercontent.com/u/27892099?v=4)](https://github.com/denizgolbas "denizgolbas (10 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (10 commits)")[![megasteve19](https://avatars.githubusercontent.com/u/32229751?v=4)](https://github.com/megasteve19 "megasteve19 (4 commits)")

---

Tags

laravellaravel-frameworklaravel-packagemysqlpartitionpartitioningpostgrespostgresqllaraveldatabasepostgresmigrationspostgrepsqlORPTechlaravel-migration-partition

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/orptech-laravel-migration-partition/health.svg)

```
[![Health](https://phpackages.com/badges/orptech-laravel-migration-partition/health.svg)](https://phpackages.com/packages/orptech-laravel-migration-partition)
```

###  Alternatives

[spatie/laravel-backup

A Laravel package to backup your application

6.0k21.8M191](/packages/spatie-laravel-backup)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[cybercog/laravel-clickhouse

ClickHouse migrations for Laravel

163166.8k](/packages/cybercog-laravel-clickhouse)[toponepercent/baum

Baum is an implementation of the Nested Set pattern for Eloquent models.

3154.7k](/packages/toponepercent-baum)

PHPackages © 2026

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