|
1 | | -<?xml version="1.0" encoding="UTF-8"?> |
2 | | -<!-- |
3 | | -
|
4 | | - Copyright 2010-2016 the original author or authors. |
5 | | -
|
6 | | - Licensed under the Apache License, Version 2.0 (the "License"); |
7 | | - you may not use this file except in compliance with the License. |
8 | | - You may obtain a copy of the License at |
9 | | -
|
10 | | - http://www.apache.org/licenses/LICENSE-2.0 |
11 | | -
|
12 | | - Unless required by applicable law or agreed to in writing, software |
13 | | - distributed under the License is distributed on an "AS IS" BASIS, |
14 | | - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15 | | - See the License for the specific language governing permissions and |
16 | | - limitations under the License. |
17 | | -
|
18 | | ---> |
19 | | -<document xmlns="http://maven.apache.org/XDOC/2.0" |
20 | | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
21 | | - xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd"> |
22 | | - |
23 | | - <properties> |
24 | | - <title>MyBatis Migrations | Migrate > bootstrap</title> |
25 | | - < author email= "[email protected]">The MyBatis Team</ author> |
26 | | - </properties> |
27 | | - |
28 | | - <body> |
29 | | - <section name="The 'bootstrap' command"> |
30 | | - <p>If you’re working from an existing database, you need to start from a known state. There’s no point in trying |
31 | | - to rewind time and shoehorn your existing database into a series of migration scripts. It’s more practical to just |
32 | | - accept the current state of your database schema and identify this as the starting point. The bootstrap script and |
33 | | - command exist for this reason.</p> |
34 | | - |
35 | | - <p> In the scripts directory you’ll find <code>bootstrap.sql</code>. You can put your |
36 | | - existing DDLscript in this file. If you don’t have a DDL script, you can export your existing database schema and |
37 | | - put it in the bootstrap file. You’ll want to clean it up so that it doesn’t contain anything specific to any one |
38 | | - environment, but otherwise almost any script should work. Watch out for DDL that contains conditional elements or |
39 | | - branching logic that could generate multiple schemas. While this is sometimes necessary, it’s a really good idea |
40 | | - to try to eliminate this aspect of your database schema (put such conditional and branching logic in your code or |
41 | | - stored procedures instead). If you have multiple DDL files, you’ll have to merge them into the single bootstrap |
42 | | - file.</p> |
43 | | - |
44 | | - <p>But worry not, it’s the last time you’ll ever modify it. One of the rules above was immutable change scripts... |
45 | | - the bootstrap is included in that rule.</p> |
46 | | - |
47 | | - <p><span class="label warning">Note</span> The bootstrap.sql is a plain text file and is not a valid “migration” |
48 | | - that you’ll learn about later. It’s meant to be similar to the scripts you probably already use. Therefore you |
49 | | - cannot rollback the bootstrap file, nor is it tracked in the audit logs... without exception, whatever you put in |
50 | | - the bootstrap file cannot leverage the benefits of the other migration commands. But we have to start somewhere, |
51 | | - and it’s best to look forward.</p> |
52 | | - |
53 | | - <p>To run the bootstrap file, you simply call the bootstrap command. You do this once to initialize your database |
54 | | - into a known working state. From then on, you’ll use migration scripts to evolve the database schema.</p> |
55 | | - |
56 | | - <p>The bootstrap command has no parameters. So running it is as simple as:</p> |
57 | | - |
58 | | - <source>/home/cbegin/testdb$ migrate bootstrap</source> |
59 | | - |
60 | | - <p>As usual, you can use the <code>--path</code> option to specify the repository path, otherwise the current |
61 | | - working directory is assumed to be the root of your migration repository (aka migration path).</p> |
62 | | - |
63 | | - <p>If there are environment specific elements in your bootstrap script, you’ll learn later that you can use |
64 | | - properties to deal with those.</p> |
65 | | - </section> |
66 | | - </body> |
67 | | - |
68 | | -</document> |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | +<!-- |
| 3 | +
|
| 4 | + Copyright 2010-2016 the original author or authors. |
| 5 | +
|
| 6 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | + you may not use this file except in compliance with the License. |
| 8 | + You may obtain a copy of the License at |
| 9 | +
|
| 10 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +
|
| 12 | + Unless required by applicable law or agreed to in writing, software |
| 13 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + See the License for the specific language governing permissions and |
| 16 | + limitations under the License. |
| 17 | +
|
| 18 | +--> |
| 19 | +<document xmlns="http://maven.apache.org/XDOC/2.0" |
| 20 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 21 | + xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd"> |
| 22 | + |
| 23 | + <properties> |
| 24 | + <title>MyBatis Migrations | Migrate > bootstrap</title> |
| 25 | + < author email= "[email protected]">The MyBatis Team</ author> |
| 26 | + </properties> |
| 27 | + |
| 28 | + <body> |
| 29 | + <section name="The 'bootstrap' command"> |
| 30 | + <p>If you’re working from an existing database, you need to start from a known state. There’s no point in trying |
| 31 | + to rewind time and shoehorn your existing database into a series of migration scripts. It’s more practical to just |
| 32 | + accept the current state of your database schema and identify this as the starting point. The bootstrap script and |
| 33 | + command exist for this reason.</p> |
| 34 | + |
| 35 | + <p> In the scripts directory you’ll find <code>bootstrap.sql</code>. You can put your |
| 36 | + existing DDLscript in this file. If you don’t have a DDL script, you can export your existing database schema and |
| 37 | + put it in the bootstrap file. You’ll want to clean it up so that it doesn’t contain anything specific to any one |
| 38 | + environment, but otherwise almost any script should work. Watch out for DDL that contains conditional elements or |
| 39 | + branching logic that could generate multiple schemas. While this is sometimes necessary, it’s a really good idea |
| 40 | + to try to eliminate this aspect of your database schema (put such conditional and branching logic in your code or |
| 41 | + stored procedures instead). If you have multiple DDL files, you’ll have to merge them into the single bootstrap |
| 42 | + file.</p> |
| 43 | + |
| 44 | + <p>But worry not, it’s the last time you’ll ever modify it. One of the rules above was immutable change scripts... |
| 45 | + the bootstrap is included in that rule.</p> |
| 46 | + |
| 47 | + <p><span class="label warning">Note</span> The bootstrap.sql is a plain text file and is not a valid “migration” |
| 48 | + that you’ll learn about later. It’s meant to be similar to the scripts you probably already use. Therefore you |
| 49 | + cannot rollback the bootstrap file, nor is it tracked in the audit logs... without exception, whatever you put in |
| 50 | + the bootstrap file cannot leverage the benefits of the other migration commands. But we have to start somewhere, |
| 51 | + and it’s best to look forward.</p> |
| 52 | + |
| 53 | + <p>To run the bootstrap file, you simply call the bootstrap command. You do this once to initialize your database |
| 54 | + into a known working state. From then on, you’ll use migration scripts to evolve the database schema.</p> |
| 55 | + |
| 56 | + <p>The bootstrap command has no parameters. So running it is as simple as:</p> |
| 57 | + |
| 58 | + <source>/home/cbegin/testdb$ migrate bootstrap</source> |
| 59 | + |
| 60 | + <p>As usual, you can use the <code>--path</code> option to specify the repository path, otherwise the current |
| 61 | + working directory is assumed to be the root of your migration repository (aka migration path).</p> |
| 62 | + |
| 63 | + <p>If there are environment specific elements in your bootstrap script, you’ll learn later that you can use |
| 64 | + properties to deal with those.</p> |
| 65 | + </section> |
| 66 | + </body> |
| 67 | + |
| 68 | +</document> |
0 commit comments