/
migrate.html
286 lines (276 loc) · 9.79 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
---
layout: gradle
pill: migrate
subtitle: 'gradle flywayMigrate'
---
<div id="gradleMigrate">
<h1>Gradle Task: flywayMigrate</h1>
<p>Migrates the schema to the latest version. Flyway will create the metadata table automatically if it doesn't
exist.</p>
<a href="/documentation/command/migrate"><img src="/assets/balsamiq/command-migrate.png" alt="migrate"></a>
<h2>Usage</h2>
<pre class="console">> gradle flywayMigrate</pre>
<h2>Configuration</h2>
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>Parameter</th>
<th>Required</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>url</td>
<td>YES</td>
<td></td>
<td>The jdbc url to use to connect to the database</td>
</tr>
<tr>
<td>driver</td>
<td>NO</td>
<td><i>Auto-detected based on url</i></td>
<td>The fully qualified classname of the jdbc driver to use
to connect to the database
</td>
</tr>
<tr>
<td>user</td>
<td>NO</td>
<td></td>
<td>The user to use to connect to the database</td>
</tr>
<tr>
<td>password</td>
<td>NO</td>
<td></td>
<td>The password to use to connect to the database</td>
</tr>
<tr>
<td>schemas</td>
<td>NO</td>
<td><i>default schema of the connection</i></td>
<td>Case-sensitive list of schemas managed by Flyway.<br/>
The first schema in the list will be automatically set as the default one during
the migration. It will also be the one containing the metadata table.
</td>
</tr>
<tr>
<td>table</td>
<td>NO</td>
<td>schema_version</td>
<td>The name of Flyway's metadata table.<br/>By
default (single-schema mode) the metadata table is placed in the default schema for the connection
provided by the datasource.<br/>When the <i>flyway.schemas</i> property is set (multi-schema mode),
the metadata table is placed in the first schema of the list.
</td>
</tr>
<tr>
<td>locations</td>
<td>NO</td>
<td>filesystem:src/main/resources/db/migration</td>
<td>Locations to scan recursively for migrations. The location type is determined by its prefix.<br/>
Unprefixed locations or locations starting with <code>classpath:</code> point to a package on the
classpath and may contain both sql and java-based migrations.<br/>
Locations starting with <code>filesystem:</code> point to a directory on the filesystem and may only
contain sql migrations.
</td>
</tr>
<tr>
<td>sqlMigrationPrefix</td>
<td>NO</td>
<td>V</td>
<td>The file name prefix for Sql migrations</td>
</tr>
<tr>
<td>repeatableSqlMigrationPrefix</td>
<td>NO</td>
<td>R</td>
<td>The file name prefix for repeatable Sql migrations</td>
</tr>
<tr>
<td>sqlMigrationSeparator</td>
<td>NO</td>
<td>__</td>
<td>The file name separator for Sql migrations</td>
</tr>
<tr>
<td>sqlMigrationSuffix</td>
<td>NO</td>
<td>.sql</td>
<td>The file name suffix for Sql migrations</td>
</tr>
<tr>
<td>encoding</td>
<td>NO</td>
<td>UTF-8</td>
<td>The encoding of Sql migrations</td>
</tr>
<tr>
<td>placeholderReplacement</td>
<td>NO</td>
<td>true</td>
<td>Whether placeholders should be replaced</td>
</tr>
<tr>
<td>placeholders</td>
<td>NO</td>
<td></td>
<td>Placeholders to replace in Sql migrations</td>
</tr>
<tr>
<td>placeholderPrefix</td>
<td>NO</td>
<td>${</td>
<td>The prefix of every placeholder</td>
</tr>
<tr>
<td>placeholderSuffix</td>
<td>NO</td>
<td>}
</td>
<td>The suffix of every placeholder</td>
</tr>
<tr>
<td>resolvers</td>
<td>NO</td>
<td></td>
<td>Fully qualified class names of custom
<a href="/documentation/api/javadoc/org/flywaydb/core/api/resolver/MigrationResolver">MigrationResolver</a>
implementations to be used in addition to the built-in ones for resolving Migrations to apply.</td>
</tr>
<tr>
<td>callbacks</td>
<td>NO</td>
<td></td>
<td>Fully qualified class names of
<a href="/documentation/api/javadoc/org/flywaydb/core/api/callback/FlywayCallback">FlywayCallback</a>
implementations to use to hook into the Flyway lifecycle.</td>
</tr>
<tr>
<td>skipDefaultCallbacks</td>
<td>NO</td>
<td>false</td>
<td>Whether default built-in callbacks (sql) should be skipped. If true, only custom callbacks are used.</td>
</tr>
<tr>
<td>target</td>
<td>NO</td>
<td><i>latest version</i></td>
<td>The target version up to which Flyway should run
migrations. Migrations with a higher version number will not be applied. The string 'current' will be
interpreted as MigrationVersion.CURRENT, a placeholder for the latest version that has been applied to the
database.
</td>
</tr>
<tr>
<td>outOfOrder</td>
<td>NO</td>
<td>false</td>
<td>Allows migrations to be run "out of order".
<p>If you already have versions 1 and 3 applied, and now a version 2 is found,
it will be applied too instead of being ignored.</p>
</td>
</tr>
<tr>
<td>validateOnMigrate</td>
<td>NO</td>
<td>true</td>
<td>Whether to automatically call validate or not when running migrate.<br/>
For each sql migration a CRC32 checksum is calculated
when the sql script is executed. The validate mechanism checks if the sql migration in the classpath
still has the same checksum as the sql migration already executed in the database.<br/></td>
</tr>
<tr>
<td>cleanOnValidationError</td>
<td>NO</td>
<td>false</td>
<td>Whether to automatically call clean or not when a validation error occurs.<br/><br/>
This is exclusively intended as a convenience for development. Even tough we
strongly recommend not to change migration scripts once they have been checked into SCM and run, this
provides a way of dealing with this case in a smooth manner. The database will be wiped clean
automatically, ensuring that the next migration will bring you back to the state checked into
SCM.<br/><br/><strong>Warning ! Do not enable in production !</strong>
</td>
</tr>
<tr>
<td>cleanDisabled</td>
<td>NO</td>
<td>false</td>
<td>Whether to disable clean. This is especially useful for production environments where running clean can be quite a career limiting move.</td>
</tr>
<tr>
<td>baselineOnMigrate</td>
<td>NO</td>
<td>false</td>
<td>Whether to automatically call baseline when migrate is executed against a non-empty schema with no metadata
table.
This schema will then be baselined with the <code>baselineVersion</code> before executing the migrations.
Only migrations above <code>baselineVersion</code> will then be applied.<br/>
<p>This is useful for initial Flyway production deployments on projects with an existing DB.</p>
<p>Be careful when enabling this as it removes the safety net that ensures Flyway does not migrate the wrong
database in case of a configuration mistake!</p>
</td>
</tr>
<tr>
<td>baselineVersion</td>
<td>NO</td>
<td>1</td>
<td>The version to tag an existing schema with when executing baseline</td>
</tr>
<tr>
<td>baselineDescription</td>
<td>NO</td>
<td>
<nobr><< Flyway Baseline >></nobr>
</td>
<td>The description to tag an existing schema with when executing baseline</td>
</tr>
</tbody>
</table>
<h2>Sample configuration</h2>
<pre class="prettyprint">flyway {
driver = 'org.hsqldb.jdbcDriver'
url = 'jdbc:hsqldb:file:/db/flyway_sample;shutdown=true'
user = 'SA'
password = 'mySecretPwd'
schemas = ['schema1', 'schema2', 'schema3']
table = 'schema_history'
locations = ['classpath:migrations1', 'migrations2', 'filesystem:/sql-migrations']
sqlMigrationPrefix = 'Migration-'
repeatableSqlMigrationPrefix = 'RRR'
sqlMigrationSeparator = '__'
sqlMigrationSuffix = '-OK.sql'
encoding = 'ISO-8859-1'
placeholderReplacement = true
placeholders = [
'aplaceholder' : 'value',
'otherplaceholder' : 'value123'
]
placeholderPrefix = '#['
placeholderSuffix = ']'
resolvers = ['com.mycompany.proj.CustomResolver', 'com.mycompany.proj.AnotherResolver']
callbacks = ['com.mycompany.proj.CustomCallback', 'com.mycompany.proj.AnotherCallback']
skipDefaultCallbacks = false
target = '1.1'
outOfOrder = false
validateOnMigrate = true
cleanOnValidationError = false
cleanDisabled = false
baselineOnMigrate = false
baselineVersion = 5
baselineDescription = "Let's go!"
}</pre>
<h2>Sample output</h2>
<pre class="console">> gradle flywayMigrate -i
Current schema version: 0
Migrating to version 1
Migrating to version 1.1
Migrating to version 1.2
Migrating to version 1.3
Successfully applied 4 migrations (execution time 00:00.091s).</pre>
<p class="next-steps">
<a class="btn btn-primary" href="/documentation/gradle/clean">Gradle: clean <i class="fa fa-arrow-right"></i></a>
</p>
</div>