Skip to content

Commit c65aa08

Browse files
committed
Updated the README.md according to the updates. Updated the input data types of hash partition compiler.
1 parent bf05e20 commit c65aa08

File tree

3 files changed

+50
-8
lines changed

3 files changed

+50
-8
lines changed

README.md

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,28 +44,70 @@ use Illuminate\Support\Facades\Schema;
4444
```
4545

4646
### Template Usage
47+
48+
#### Range Partition
49+
4750
```php
4851
use ORPTech\MigrationPartition\Database\Schema\Blueprint;
4952
use ORPTech\MigrationPartition\Support\Facades\Schema;
5053

51-
Schema::createPartitioned('[YourTableNameHere]', function (Blueprint $table) {
54+
Schema::createRangePartitioned('[YourTableNameHere]', function (Blueprint $table) {
5255
//...
5356
}, '[compositeKeyOne]', '[compositeKeyTwo]', '[rangePartitionKey]');
5457
```
5558

59+
#### List Partition
60+
61+
```php
62+
use ORPTech\MigrationPartition\Database\Schema\Blueprint;
63+
use ORPTech\MigrationPartition\Support\Facades\Schema;
64+
65+
Schema::createListPartitioned('[YourTableNameHere]', function (Blueprint $table) {
66+
//...
67+
}, '[compositeKeyOne]', '[compositeKeyTwo]', '[listPartitionKey]');
68+
```
69+
70+
#### Hash Partition
71+
72+
```php
73+
use ORPTech\MigrationPartition\Database\Schema\Blueprint;
74+
use ORPTech\MigrationPartition\Support\Facades\Schema;
75+
76+
Schema::createHashPartitioned('[YourTableNameHere]', function (Blueprint $table) {
77+
//...
78+
}, '[compositeKeyOne]', '[compositeKeyTwo]', '[hashPartitionKey]');
79+
```
80+
5681
### Important
5782
- This package currently supports PostgreSQL Range Partitions.
5883
- You shouldn't define any primary keys in your migration. The package creates a composite key while setting up the table.
5984
- You need to create an initial partition to start using the tables. (PostgreSQL)
6085

86+
#### Range Partition
87+
88+
```php
89+
use ORPTech\MigrationPartition\Database\Schema\Blueprint;
90+
use ORPTech\MigrationPartition\Support\Facades\Schema;
91+
92+
Schema::attachRangePartition('[YourCreatedPartitionTableNameHere]', function (Blueprint $table) {}, '[SubfixForPartition]', '[StartDate]', '[EndDate]');
93+
```
94+
95+
#### List Partition
96+
6197
```php
62-
Schema::attachPartition('[YourCreatedPartitionTableNameHere]', function (Blueprint $table) {}, '[SubfixForPartition]', '[StartDate]', '[EndDate]');
98+
use ORPTech\MigrationPartition\Database\Schema\Blueprint;
99+
use ORPTech\MigrationPartition\Support\Facades\Schema;
100+
101+
Schema::attachListPartition('[YourCreatedPartitionTableNameHere]', function (Blueprint $table) {}, '[SubfixForPartition]', '[listPartitionValue]');
63102
```
64103

65-
#### OR
104+
#### Hash Partition
66105

67106
```php
68-
DB::statement("CREATE TABLE [partition_name_here] PARTITION OF [table_name_here] FOR VALUES FROM [starting_value_here] TO [end_value_here]");
107+
use ORPTech\MigrationPartition\Database\Schema\Blueprint;
108+
use ORPTech\MigrationPartition\Support\Facades\Schema;
109+
110+
Schema::attachHashPartition('[YourCreatedPartitionTableNameHere]', function (Blueprint $table) {}, '[SubfixForPartition]', '[hashModulus]', '[hashRemainder]');
69111
```
70112

71113
## Testing

src/Database/Schema/Builder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ public function createHashPartitioned(string $table, Closure $callback, string $
130130
* @param string $table
131131
* @param \Closure $callback
132132
* @param string $subfixForPartition
133-
* @param string $hashModulus
134-
* @param string $hashRemainder
133+
* @param int $hashModulus
134+
* @param int $hashRemainder
135135
* @return void
136136
*/
137-
public function attachHashPartition(string $table, Closure $callback, string $subfixForPartition, string $hashModulus, string $hashRemainder)
137+
public function attachHashPartition(string $table, Closure $callback, string $subfixForPartition, int $hashModulus, int $hashRemainder)
138138
{
139139
$this->build(tap($this->createBlueprint($table), function ($blueprint) use ($callback, $subfixForPartition, $hashModulus, $hashRemainder) {
140140
$blueprint->attachHashPartition();

src/Support/Facades/Schema.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* @method static createListPartitioned(string $table, \Closure $callback, string $pkCompositeOne, string $pkCompositeTwo, string $listPartitionKey)
1313
* @method static attachListPartition(string $table, \Closure $callback, string $subfixForPartition, string $listPartitionValue)
1414
* @method static createHashPartitioned(string $table, \Closure $callback, string $pkCompositeOne, string $pkCompositeTwo, string $hashPartitionKey)
15-
* @method static attachHashPartition(string $table, \Closure $callback, string $subfixForPartition, string $hashModulus, string $hashRemainder)
15+
* @method static attachHashPartition(string $table, \Closure $callback, string $subfixForPartition, int $hashModulus, int $hashRemainder)
1616
* @see \ORPTech\MigrationPartition\Database\Schema\Builder
1717
*/
1818
class Schema extends Facade

0 commit comments

Comments
 (0)