This package extends Illuminate to provide partitioned table creation in migrations.

Overview

Laravel Partitions for Migrations

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 GitHub Tests Action Status Total Downloads

ORPTech

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 protect your business.

Installation

You can install the package via composer:

composer require orptech/laravel-migration-partition

DBMS Support

  • PostgreSQL

Planned Development

  • MySQL
  • MariaDB
  • SQL Server 2017+
  • SQLite 3.8.8+

Usage

This package currently, only supports 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

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

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

Template Usage

Range Partition

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

Schema::createRangePartitioned('[YourTableNameHere]', function (Blueprint $table) {
    //...
}, '[compositeKeyOne]', '[compositeKeyTwo]', '[rangePartitionKey]');
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
use ORPTech\MigrationPartition\Database\Schema\Blueprint;
use ORPTech\MigrationPartition\Support\Facades\Schema;

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

List Partition

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

Schema::createListPartitioned('[YourTableNameHere]', function (Blueprint $table) {
    //...
}, '[compositeKeyOne]', '[compositeKeyTwo]', '[listPartitionKey]');
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
use ORPTech\MigrationPartition\Database\Schema\Blueprint;
use ORPTech\MigrationPartition\Support\Facades\Schema;

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

Hash Partition

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

Schema::createHashPartitioned('[YourTableNameHere]', function (Blueprint $table) {
    //...
}, '[compositeKeyOne]', '[compositeKeyTwo]', '[hashPartitionKey]');
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
use ORPTech\MigrationPartition\Database\Schema\Blueprint;
use ORPTech\MigrationPartition\Support\Facades\Schema;

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

Removing a Partition

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

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

Commands

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

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

php artisan partition:list
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

This command will list all the partitioned tables.

php artisan partition:partitions

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

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

You might also like...
Création d'un livre d’or permettant aux utilisateurs de laisser leurs avis sur le site internet.

📚 Livre d'or 📚 // Création d'un livre d’or permettant aux utilisateurs de laisser leurs avis sur le site internet. // 📋 Description du projet Créat

PlayZ is an esport event organization and management website allowing the creation of tournaments on the most popular video games of the esport scene.

PlayZ the playz to play Table of Contents Description "What is Playz?" In one sentence PlayZ is "an esport event organization and management website a

Validate PHP database migration files for compliance with best practices. Ensure db migrations are irreversible.
Validate PHP database migration files for compliance with best practices. Ensure db migrations are irreversible.

PHP DB Migration Validator Introduction In modern PHP frameworks such as Symfony and Laravel, migrations usually have up and down methods. In up metho

Allow your model to record the creation, update and deletion of user fingerprints in laravel packages

This laravel package will allow your models to record the the created, updated and deleted by User FingerPrints

Declare database migrations and factory definitions inside Laravel models.

Lucid This package allows you to declare database migrations and factory definitions inside of your Laravel models. Running the lucid:migrate command

Easily add all the 58 Algerian Wilayas and its Dairas to your cool Laravel project (Migrations, Seeders and Models).
Easily add all the 58 Algerian Wilayas and its Dairas to your cool Laravel project (Migrations, Seeders and Models).

Laravel-Algereography Laravel-Algereography allows you to add Migrations, Seeders and Models of Algerian Wilayas and Dairas to your existing or new co

Laravel MiGator - Migrations Generator
Laravel MiGator - Migrations Generator

Laravel Migator A package that will allow developers to interactively generate schema migrations for a laravel application. It takes into account the

View themes is a simple package to provide themed view support to Laravel.

Laravel View Themes View themes is a simple package to provide themed view support to Laravel. Installation Add alexwhitman/view-themes to the require

Slim Jam is a demo application to provide examples for composer package, PHPSpreadsheet, Shopify API etc. usages.

SLIM JAM Slim Jam is a demo application to provide examples for composer package, PHPSpreadsheet, Shopify API etc. usages. This project aims to take a

Comments
Releases(v3.0.0)
  • v3.0.0(Oct 12, 2022)

    • Series partition creation commands for range, list and hash partitions.
    • New naming convention in order to provide extendability.
    • Ability to attach, and detach partitions.
    • Support for native Illuminate methods.
    • Updated README to provide more in-depth usage guidance.

    This is a major release and is NOT backward compatible.

    Source code(tar.gz)
    Source code(zip)
  • v2.0.0(Oct 10, 2022)

  • v1.0.6(Oct 8, 2022)

  • v1.0.5(Oct 6, 2022)

  • v1.0.4(Oct 6, 2022)

    In order to work with partitions, PostgreSQL requires tables to be created as "partitioned table", and it's impossible to convert a regular table into a partitioned one. Solutions on the internet show that people use raw queries to make their tables when they are using Laravel and PostgreSQL. They lose the beauty of Laravel and its features. With this package, users can use the new Schema static method to create their partitioned table.

    Source code(tar.gz)
    Source code(zip)
  • v1.0.3(Oct 6, 2022)

    In order to work with partitions, PostgreSQL requires tables to be created as "partitioned table", and it's impossible to convert a regular table into a partitioned one. Solutions on the internet show that people use raw queries to make their tables when they are using Laravel and PostgreSQL. They lose the beauty of Laravel and its features. With this package, users can use the new Schema static method to create their partitioned table.

    Source code(tar.gz)
    Source code(zip)
Owner
ORPTech
A technology company based in Cyprus.
ORPTech
Firebird Illuminate package for Laravel 5

laravel-firebird Please Note: This package has been abandoned by it's creator, when I created it there were no other decent laravel packages around an

Jacques van Zuydam 62 Jan 26, 2022
This package extends Laravel's FormBuilder to include some (soon all) HTML5 elements

HTML5 Forms for Laravel This package extends Laravel's FormBuilder to include some (soon all) HTML5 elements. How to Install Install the braunson/lara

Braunson Yager 89 Jun 17, 2022
A Collections-only split from Laravel's Illuminate Support

Collect - Illuminate Collections Deprecated: With the separation of Illuminate's Collections package, Collect is no longer necessary ?? . We will main

Tighten 1.5k Dec 28, 2022
A Collections-only split from Laravel's Illuminate Support

Collect - Illuminate Collections Deprecated: With the separation of Illuminate's Collections package, Collect is no longer necessary ?? . We will main

Tighten 1.5k Dec 30, 2022
A simple package to manage the creation of a structure composed of the service and repository layers in a Laravel application

Chapolim Este projeto tem como objetivo fornecer alguns comandos adicionais à interface de linha de comando do Laravel, o Artisan, para manipular a es

Eliezer Alves 51 Dec 11, 2022
Laravel Grid is a package that helps you display table data.

Laravel Grid Laravel Grid is a package that helps you display table data. I could not find package that would satisfy my needs so I decided to write o

null 9 Nov 29, 2022
Data Table package with server-side processing, unlimited exporting and VueJS components

Data Table package with server-side processing, unlimited exporting and VueJS components. Quickly build any complex table based on a JSON template.

Laravel Enso 618 Dec 28, 2022
Easy creation of slugs for your Eloquent models in Laravel

Eloquent-Sluggable Easy creation of slugs for your Eloquent models in Laravel. NOTE: These instructions are for the latest version of Laravel. If you

Colin Viebrock 3.6k Dec 30, 2022
Automatic Laravel model migrations.

Laravel Automatic Migrations Automatic Laravel model migrations. Instead of having to create and manage migration files, this package allows you to sp

null 38 Nov 11, 2022
Blacksmith is a code generation tool which automates the creation of common files that you'd typically create for each entity in your application.

Blacksmith is a code generation tool which automates the creation of common files that you'd typically create for each entity in your application.

Indatus 197 Dec 30, 2022