|
1
|
|
|
<?php namespace Bosnadev\Database\Schema; |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Class Blueprint |
|
5
|
|
|
* @package Bosnadev\Database\Schema |
|
6
|
|
|
*/ |
|
7
|
|
|
class Blueprint extends \Illuminate\Database\Schema\Blueprint |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* Add the index commands fluently specified on columns. |
|
11
|
|
|
* |
|
12
|
|
|
* @return void |
|
13
|
|
|
*/ |
|
14
|
33 |
|
protected function addFluentIndexes() |
|
15
|
|
|
{ |
|
16
|
33 |
|
foreach ($this->columns as $column) { |
|
17
|
30 |
|
foreach (array('primary', 'unique', 'index', 'gin') as $index) { |
|
18
|
|
|
// If the index has been specified on the given column, but is simply |
|
19
|
|
|
// equal to "true" (boolean), no name has been specified for this |
|
20
|
|
|
// index, so we will simply call the index methods without one. |
|
21
|
30 |
|
if ($column->$index === true) { |
|
22
|
|
|
$this->$index($column->name); |
|
23
|
|
|
|
|
24
|
|
|
continue 2; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
// If the index has been specified on the column and it is something |
|
28
|
|
|
// other than boolean true, we will assume a name was provided on |
|
29
|
|
|
// the index specification, and pass in the name to the method. |
|
30
|
30 |
|
elseif (isset($column->$index)) { |
|
31
|
|
|
$this->$index($column->name, $column->$index); |
|
32
|
|
|
|
|
33
|
|
|
continue 2; |
|
34
|
|
|
} |
|
35
|
30 |
|
} |
|
36
|
33 |
|
} |
|
37
|
33 |
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Specify an index for the table. |
|
41
|
|
|
* |
|
42
|
|
|
* @param string|array $columns |
|
43
|
|
|
* @param string $name |
|
44
|
|
|
* @return \Illuminate\Support\Fluent |
|
45
|
|
|
*/ |
|
46
|
6 |
|
public function gin($columns, $name = null) |
|
47
|
|
|
{ |
|
48
|
6 |
|
return $this->indexCommand('gin', $columns, $name); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Create a new character column on the table. |
|
53
|
|
|
* |
|
54
|
|
|
* @param string $column |
|
55
|
|
|
* @param int $length |
|
56
|
|
|
* @return \Illuminate\Support\Fluent |
|
57
|
|
|
*/ |
|
58
|
6 |
|
public function character($column, $length = 255) |
|
59
|
|
|
{ |
|
60
|
6 |
|
return $this->addColumn('character', $column, compact('length')); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @param $column |
|
65
|
|
|
* @return \Illuminate\Support\Fluent |
|
66
|
|
|
*/ |
|
67
|
6 |
|
public function hstore($column) |
|
68
|
|
|
{ |
|
69
|
6 |
|
return $this->addColumn('hstore', $column); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @param $column |
|
74
|
|
|
* @return \Illuminate\Support\Fluent |
|
75
|
|
|
*/ |
|
76
|
6 |
|
public function uuid($column) |
|
77
|
|
|
{ |
|
78
|
6 |
|
return $this->addColumn('uuid', $column); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Create a new jsonb column on the table |
|
83
|
|
|
* |
|
84
|
|
|
* @param $column |
|
85
|
|
|
* @return \Illuminate\Support\Fluent |
|
86
|
|
|
*/ |
|
87
|
6 |
|
public function jsonb($column) |
|
88
|
|
|
{ |
|
89
|
6 |
|
return $this->addColumn('jsonb', $column); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Create a new int4range column on the table. |
|
94
|
|
|
* |
|
95
|
|
|
* @param string $column |
|
96
|
|
|
* |
|
97
|
|
|
* @return \Illuminate\Support\Fluent |
|
98
|
|
|
*/ |
|
99
|
6 |
|
public function int4range($column) |
|
100
|
|
|
{ |
|
101
|
6 |
|
return $this->addColumn('int4range', $column); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* Create a new int8range column on the table. |
|
106
|
|
|
* |
|
107
|
|
|
* @param string $column |
|
108
|
|
|
* |
|
109
|
|
|
* @return \Illuminate\Support\Fluent |
|
110
|
|
|
*/ |
|
111
|
6 |
|
public function int8range($column) |
|
112
|
|
|
{ |
|
113
|
6 |
|
return $this->addColumn('int8range', $column); |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* Create a new numrange column on the table. |
|
118
|
|
|
* |
|
119
|
|
|
* @param string $column |
|
120
|
|
|
* |
|
121
|
|
|
* @return \Illuminate\Support\Fluent |
|
122
|
|
|
*/ |
|
123
|
6 |
|
public function numrange($column) |
|
124
|
|
|
{ |
|
125
|
6 |
|
return $this->addColumn('numrange', $column); |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* Create a new tsrange column on the table. |
|
130
|
|
|
* |
|
131
|
|
|
* @param string $column |
|
132
|
|
|
* |
|
133
|
|
|
* @return \Illuminate\Support\Fluent |
|
134
|
|
|
*/ |
|
135
|
6 |
|
public function tsrange($column) |
|
136
|
|
|
{ |
|
137
|
6 |
|
return $this->addColumn('tsrange', $column); |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
/** |
|
141
|
|
|
* Create a new tstzrange column on the table. |
|
142
|
|
|
* |
|
143
|
|
|
* @param string $column |
|
144
|
|
|
* |
|
145
|
|
|
* @return \Illuminate\Support\Fluent |
|
146
|
|
|
*/ |
|
147
|
6 |
|
public function tstzrange($column) |
|
148
|
|
|
{ |
|
149
|
6 |
|
return $this->addColumn('tstzrange', $column); |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
/** |
|
153
|
|
|
* Create a new daterange column on the table. |
|
154
|
|
|
* |
|
155
|
|
|
* @param $column |
|
156
|
|
|
* |
|
157
|
|
|
* @return \Illuminate\Support\Fluent |
|
158
|
|
|
*/ |
|
159
|
3 |
|
public function daterange($column) |
|
160
|
|
|
{ |
|
161
|
3 |
|
return $this->addColumn('daterange', $column); |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
/** |
|
165
|
|
|
* Create a new inet column on the table. |
|
166
|
|
|
* |
|
167
|
|
|
* @param $column |
|
168
|
|
|
* |
|
169
|
|
|
* @return \Illuminate\Support\Fluent |
|
170
|
|
|
*/ |
|
171
|
|
|
public function inet($column) |
|
172
|
|
|
{ |
|
173
|
|
|
return $this->addColumn('inet', $column); |
|
174
|
|
|
} |
|
175
|
|
|
} |
|
176
|
|
|
|