-
Notifications
You must be signed in to change notification settings - Fork 232
/
Copy pathmigrate.html
308 lines (297 loc) · 8.66 KB
/
migrate.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./../assets/css/combined.css?20170912">
<link rel="shortcut icon" href="./../favicon.ico" />
<script src="https://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
var path = './../';
var class_prefix = "Migrate::";
</script>
<script src="./../assets/js/combined.js?20170912"></script>
<title>Migrate - Classes - FuelPHP Documentation</title>
</head>
<body>
<div id="container">
<header id="header">
<div class="table">
<div id="cse">
<gcse:searchbox-only newWindow="true"></gcse:searchbox-only>
</div>
<h1>
<a href="https://fuelphp.com"><img height="37px" width="147px" src="./../assets/img/fuel.png" /></a>
<strong>Documentation</strong>
</h1>
</div>
<nav>
<div class="clear"></div>
</nav>
<a href="#" id="toc_handle">table of contents</a>
<div class="clear"></div>
</header>
<div id="main">
<h2>Migrate Class</h2>
<p>
The migrate class allows you to run, walk through and revert <a href="../general/migrations.html">Migrations</a> from your controllers.
Migrations are supported in the application, in modules and in packages.
</p>
<article>
<h4 class="method" id="method_current">current($name = 'default', $type = 'app')</h4>
<p>Migrates to the current schema set in the migration configuration file.</p>
<table class="method">
<tbody>
<tr>
<th>Static</th>
<td>Yes</td>
</tr>
<tr>
<th>Parameters</th>
<td>
<table class="parameters">
<tr>
<th>Param</th>
<th>Default</th>
<th>Description</th>
</tr>
<tr>
<th><kbd>$name</kbd></th>
<td><pre class="php"><code>'default'</code></pre></td>
<td>Name of the package or module. In case of app, 'default' is used.</td>
</tr>
<tr>
<th><kbd>$type</kbd></th>
<td><pre class="php"><code>'app'</code></pre></td>
<td>Type of migration. Valid values are 'app', 'module' and 'package'.</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>Returns</th>
<td>array</td>
</tr>
<tr>
<th>Example</th>
<td>
<pre class="php"><code>// run the migrations of the application, up to the current schema.
Migrate::current('default', 'app');
</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_latest">latest($name = 'default', $type = 'app')</h4>
<p>Migrates to the latest schema set in the migration config.</p>
<table class="method">
<tbody>
<tr>
<th>Static</th>
<td>Yes</td>
</tr>
<tr>
<th>Parameters</th>
<td>
<table class="parameters">
<tr>
<th>Param</th>
<th>Default</th>
<th>Description</th>
</tr>
<tr>
<th><kbd>$name</kbd></th>
<td><pre class="php"><code>'default'</code></pre></td>
<td>Name of the package or module. In case of app, 'default' is used.</td>
</tr>
<tr>
<th><kbd>$type</kbd></th>
<td><pre class="php"><code>'app'</code></pre></td>
<td>Type of migration. Valid values are 'app', 'module' and 'package'.</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>Returns</th>
<td>array</td>
</tr>
<tr>
<th>Example</th>
<td>
<pre class="php"><code>// run the migrations of the 'mypackage' package, up to the latest schema.
Migrate::latest('mypackage', 'package');
</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_version">version($version, $name = 'default', $type = 'app')</h4>
<p>The <strong>version</strong> method will move the migrations up or down to set the schema at a specific migration version.</p>
<table class="method">
<tbody>
<tr>
<th>Static</th>
<td>Yes</td>
</tr>
<tr>
<th>Parameters</th>
<td>
<table class="parameters">
<tr>
<th>Param</th>
<th>Default</th>
<th>Description</th>
</tr>
<tr>
<th><kbd>$version</kbd></th>
<td><i>required</i></td>
<td>The version you are migrating to. If you specify <strong>null</strong>, it will migrate to the latest version.</td>
</tr>
<tr>
<th><kbd>$name</kbd></th>
<td><pre class="php"><code>'default'</code></pre></td>
<td>Name of the package or module. In case of app, 'default' is used.</td>
</tr>
<tr>
<th><kbd>$type</kbd></th>
<td><pre class="php"><code>'app'</code></pre></td>
<td>Type of migration. Valid values are 'app', 'module' and 'package'.</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>Returns</th>
<td>array</td>
</tr>
<tr>
<th>Example</th>
<td>
<pre class="php"><code>// migrate the module 'mymodule' to version 10
Migrate::version(10, 'mymodule', 'module');
</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_up">up($version, $name = 'default', $type = 'app')</h4>
<p>The <strong>version</strong> method will move the migrations up by one, or up to a specific version if given.</p>
<table class="method">
<tbody>
<tr>
<th>Static</th>
<td>Yes</td>
</tr>
<tr>
<th>Parameters</th>
<td>
<table class="parameters">
<tr>
<th>Param</th>
<th>Default</th>
<th>Description</th>
</tr>
<tr>
<th><kbd>$version</kbd></th>
<td><i>required</i></td>
<td>The version you want to migrating up to. If you specify <strong>null</strong>, it will migrate up to the next version.</td>
</tr>
<tr>
<th><kbd>$name</kbd></th>
<td><pre class="php"><code>'default'</code></pre></td>
<td>Name of the package or module. In case of app, 'default' is used.</td>
</tr>
<tr>
<th><kbd>$type</kbd></th>
<td><pre class="php"><code>'app'</code></pre></td>
<td>Type of migration. Valid values are 'app', 'module' and 'package'.</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>Returns</th>
<td>array</td>
</tr>
<tr>
<th>Example</th>
<td>
<pre class="php"><code>// migrate the module 'mymodule' up to version 10
Migrate::up(10, 'mymodule', 'module');
</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<article>
<h4 class="method" id="method_down">down($version, $name = 'default', $type = 'app')</h4>
<p>The <strong>version</strong> method will move the migrations down by one, or down to a specific version if given.</p>
<table class="method">
<tbody>
<tr>
<th>Static</th>
<td>Yes</td>
</tr>
<tr>
<th>Parameters</th>
<td>
<table class="parameters">
<tr>
<th>Param</th>
<th>Default</th>
<th>Description</th>
</tr>
<tr>
<th><kbd>$version</kbd></th>
<td><i>required</i></td>
<td>The version you want to migrating down to. If you specify <strong>null</strong>, it will migrate down to the next version.</td>
</tr>
<tr>
<th><kbd>$name</kbd></th>
<td><pre class="php"><code>'default'</code></pre></td>
<td>Name of the package or module. In case of app, 'default' is used.</td>
</tr>
<tr>
<th><kbd>$type</kbd></th>
<td><pre class="php"><code>'app'</code></pre></td>
<td>Type of migration. Valid values are 'app', 'module' and 'package'.</td>
</tr>
</table>
</td>
</tr>
<tr>
<th>Returns</th>
<td>array</td>
</tr>
<tr>
<th>Example</th>
<td>
<pre class="php"><code>// migrate the module 'mymodule' down to version 10
Migrate::down(10, 'mymodule', 'module');
</code></pre>
</td>
</tr>
</tbody>
</table>
</article>
<p class="note">
All methods return an array, specifying a list a migration files ( file names only! ) executed.<br />
If no migrations where found, or if the version specified resulted in no migrations being executed, the array returned is empty.
</p>
</div>
<footer>
<p>
© FuelPHP Development Team 2010-2025 - <a href="https://fuelphp.com">FuelPHP</a> is released under the MIT license.
</p>
</footer>
</div>
</body>
</html>