22
33namespace ORPTech \MigrationPartition \Database \Schema ;
44
5- use Illuminate \Support \ Traits \ Macroable ;
5+ use Illuminate \Database \ Schema \ Blueprint as IlluminateBlueprint ;
66
7- class Blueprint extends \ Illuminate \ Database \ Schema \Blueprint
7+ class Blueprint extends IlluminateBlueprint
88{
9- use Macroable;
10-
119 /**
12- * Column key one for creating a composite key.
10+ * Column key one for creating a composite key for a range partitioned table .
1311 *
14- * @var bool
12+ * @var string
1513 */
1614 public $ pkCompositeOne ;
1715
1816 /**
19- * Column key two for creating a composite key.
17+ * Column key two for creating a composite key for range partitioned table .
2018 *
21- * @var bool
19+ * @var string
2220 */
2321 public $ pkCompositeTwo ;
2422
2523 /**
26- * Partition range key for creating a partitioned table.
24+ * Partition range key for creating a range partitioned table.
2725 *
28- * @var bool
26+ * @var string
2927 */
3028 public $ rangeKey ;
3129
3230 /**
33- * Partition range key for creating a partitioned table.
31+ * Partition range key for creating a range partitioned table.
3432 *
35- * @var bool
33+ * @var string
3634 */
3735 public $ subfixForPartition ;
3836
3937 /**
40- * Partition range key for creating a partitioned table.
38+ * Partition range key for creating a range partitioned table.
4139 *
42- * @var bool
40+ * @var string
4341 */
4442 public $ startDate ;
4543
4644 /**
47- * Partition range key for creating a partitioned table.
45+ * Partition range key for creating a range partitioned table.
4846 *
49- * @var bool
47+ * @var string
5048 */
5149 public $ endDate ;
5250
51+ /**
52+ * Column key for creating a table with list partition.
53+ *
54+ * @var string
55+ */
56+ public $ listPartitionKey ;
57+
58+ /**
59+ * Column key for creating list partitions.
60+ *
61+ * @var string
62+ */
63+ public $ listPartitionValue ;
64+
65+ /**
66+ * Column key for creating a table with hash partition.
67+ *
68+ * @var string
69+ */
70+ public $ hashPartitionKey ;
71+
72+ /**
73+ * Hashing modulus for creating a hash partition.
74+ *
75+ * @var int
76+ */
77+ public $ hashModulus ;
78+
79+ /**
80+ * Hashing reminder for creating a hash partition.
81+ *
82+ * @var int
83+ */
84+ public $ hashRemainder ;
85+
86+ /**
87+ * List of commands that trigger the creating function.
88+ *
89+ * @var array
90+ */
91+ private $ creators = ['create ' , 'createRangePartitioned ' , 'createListPartitioned ' , 'createHashPartitioned ' ];
5392
5493 /**
5594 * Determine if the blueprint has a create command.
@@ -59,27 +98,67 @@ class Blueprint extends \Illuminate\Database\Schema\Blueprint
5998 public function creating ()
6099 {
61100 return collect ($ this ->commands )->contains (function ($ command ) {
62- return $ command ->name === ' create ' || ' createPartitioned ' ;
101+ return in_array ( $ command ->name , $ this -> creators , false ) ;
63102 });
64103 }
65104
66105 /**
67- * Indicate that the table needs to be created with a partition.
106+ * Indicate that the table needs to be created with a range partition.
107+ *
108+ * @return \Illuminate\Support\Fluent
109+ */
110+ public function createRangePartitioned ()
111+ {
112+ return $ this ->addCommand ('createRangePartitioned ' );
113+ }
114+
115+ /**
116+ * Create a range partition and attach it to the partitioned table.
117+ *
118+ * @return \Illuminate\Support\Fluent
119+ */
120+ public function initRangePartition ()
121+ {
122+ return $ this ->addCommand ('initRangePartition ' );
123+ }
124+
125+ /**
126+ * Indicate that the table needs to be created with a list partition.
127+ *
128+ * @return \Illuminate\Support\Fluent
129+ */
130+ public function createListPartitioned ()
131+ {
132+ return $ this ->addCommand ('createListPartitioned ' );
133+ }
134+
135+ /**
136+ * Create a list partition and attach it to the partitioned table.
137+ *
138+ * @return \Illuminate\Support\Fluent
139+ */
140+ public function initListPartition ()
141+ {
142+ return $ this ->addCommand ('initListPartition ' );
143+ }
144+
145+ /**
146+ * Indicate that the table needs to be created with a hash partition.
68147 *
69148 * @return \Illuminate\Support\Fluent
70149 */
71- public function createPartitioned ()
150+ public function createHashPartitioned ()
72151 {
73- return $ this ->addCommand ('createPartitioned ' );
152+ return $ this ->addCommand ('createHashPartitioned ' );
74153 }
75154
76155 /**
77- * Create partition and attach parttioned table.
156+ * Create a hash partition and attach it to the partitioned table.
78157 *
79158 * @return \Illuminate\Support\Fluent
80159 */
81- public function attachPartition ()
160+ public function initHashPartition ()
82161 {
83- return $ this ->addCommand ('attachPartition ' );
162+ return $ this ->addCommand ('initHashPartition ' );
84163 }
85164}
0 commit comments