Last modified by christoph_lechleitner@iteg_at on 2013-01-31 07.32:56

From version 3.1
edited by 5fbc055b7cc103006957e1ae
on 2012-06-14 07.03:35
Change comment: There is no comment for this version
To version 8.1
edited by christoph_lechleitner@iteg_at
on 2013-01-31 07.32:56
Change comment: Migrated to Confluence 5.3

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.5fbc055b7cc103006957e1ae
1 +XWiki.christoph_lechleitner@iteg_at
Content
... ... @@ -1,27 +1,78 @@
1 1  = {{id name="HowTocreateandupdateDatabasesusingSchemaManagerandSchemaUpdateSnippets-Preliminary"/}}Preliminary =
2 2  
3 -The SchemaManager and SchemaEngine give you an abstracted access to the database schema of your application, allowing you to add and delete tables, columns, relations and data in the database on application updates. It uses a designated table to keep track of the current schema status, which it will check whenever it is run, and update the database if it is not at the correct version.
3 +The SchemaManager ({{code language="none"}}org.clazzes.jdbc2xml.schema.SchemaManager{{/code}}) and SchemaEngine provide means to maintain the database scheme of an application, allowing you to add and delete tables, columns, relations and data in the database along application updates.
4 4  
5 -SchemaManager ({{code language="none"}}org.clazzes.jdbc2xml.schema.SchemaManager{{/code}}) will create a table called SCHEMA_HISTORY if it can not find it the first time it is run. This table contains the following columns:
5 +=== {{id name="HowTocreateandupdateDatabasesusingSchemaManagerandSchemaUpdateSnippets-SchemaHistoryTable"/}}Schema History Table ===
6 6  
7 -{{code language="none"}}
8 -VERSION:varchar(10), not null, primary key
9 -DESCRIPTION:varchar(512), nullable
10 -CREATION_DATE:date, nullable
11 -SERIALNR:integer(5), not null
12 -{{/code}}
7 +A designated schema table, by default named SCHEMA_HISTORY, is used to keep track of the current scheme. It will be automatically at SchemaManager's first run. (% style="font-size: 10.0pt;line-height: 13.0pt;" %)SCHEMA_HISTORY contains the following columns:
13 13  
9 +|=(((
10 +
11 +)))|=(((
12 +
13 +)))
14 +|(((
15 +(% class="code" %)
16 +(((
17 +VERSION
18 +)))
19 +)))|(((
20 +(% class="code" %)
21 +(((
22 +varchar(10), not null, primary key
23 +)))
24 +)))
25 +|(((
26 +(% class="code" %)
27 +(((
28 +DESCRIPTION
29 +)))
30 +)))|(((
31 +(% class="code" %)
32 +(((
33 +varchar(512), nullable
34 +)))
35 +)))
36 +|(((
37 +(% class="code" %)
38 +(((
39 +CREATION_DATE
40 +)))
41 +)))|(((
42 +(% class="code" %)
43 +(((
44 +date, nullable
45 +)))
46 +)))
47 +|(((
48 +(% class="code" %)
49 +(((
50 +SERIALNR
51 +)))
52 +)))|(((
53 +(% class="code" %)
54 +(((
55 +integer(5), not null
56 +)))
57 +)))
58 +
59 +=== {{id name="HowTocreateandupdateDatabasesusingSchemaManagerandSchemaUpdateSnippets-CustomnameforSchemaHistoryTable"/}}Custom name for Schema History Table ===
60 +
61 +(% style="font-size: 10.0pt;line-height: 13.0pt;" %)In (% style="font-size: 10.0pt;font-weight: normal;line-height: 13.0pt;" %)heterogenous environments as well as in heavily modularized software architectures a single database may be shared by multiple parties each requiring a couple of tables.
62 +
63 +(% style="font-size: 10.0pt;font-weight: normal;line-height: 13.0pt;" %)To allow multiple modules (applications, libraries, other OSGi bundles) to use (% style="font-size: 10.0pt;line-height: 13.0pt;" %)JDBC2XML's SchemaManager concurrently within one database, as of JDBC 1.1.1 SchemaManager hold the name of the schema history table in an overwritable property, {{code language="none"}}versionHistoryTable{{/code}}. See (%%)[[JDBCTOXML-11>>url:https://jira.clazzes.org/browse/JDBCTOXML-11||shape="rect"]](% style="font-size: 10.0pt;line-height: 13.0pt;" %).
64 +
14 14  = {{id name="HowTocreateandupdateDatabasesusingSchemaManagerandSchemaUpdateSnippets-ProjectConfiguration"/}}Project Configuration =
15 15  
16 -To function correctly, SchemaManager needs a DataSource ({{code language="none"}}javax.sql.DataSource{{/code}}) and a list of TableInfo ({{code language="none"}}org.clazzes.jdbc2xml.schema.TableInfo{{/code}}) Objects, from which a database will be created if it finds an empty database. To function properly, it also needs an implementation of ISchemaEngine ({{code language="none"}}org.clazzes.jdbc2xml.schema.ISchemaEngine{{/code}}).
67 +SchemaManager requires a DataSource ({{code language="none"}}javax.sql.DataSource{{/code}}) and a list of TableInfo ({{code language="none"}}org.clazzes.jdbc2xml.schema.TableInfo{{/code}}) Objects, from which database structures will be created if an "empty" database is detected. Furthermore, an implementation of ISchemaEngine ({{code language="none"}}org.clazzes.jdbc2xml.schema.ISchemaEngine{{/code}}) is required.
17 17  
18 -Optionally, you may set the base version (default value 0.1.00) and base description String (default "initial database schema").
69 +Optionally, a base version (default value 0.1.00) and a base description String (default "initial database schema") may be specified.
19 19  
20 20  Database updates are passed as a Map<String, ISchemaUpdateSnippet> (org.clazzes.jdbc2xml.schema.ISchemaUpdateSnippet) - details see below.
21 21  
22 22  To perform the operations, call {{code language="none"}}SchemaManager.start(){{/code}}.
23 23  
24 -=== {{id name="HowTocreateandupdateDatabasesusingSchemaManagerandSchemaUpdateSnippets-UsingSpringorOSGi/Blueprint"/}}Using Spring or OSGi/Blueprint ===
75 +=== {{id name="HowTocreateandupdateDatabasesusingSchemaManagerandSchemaUpdateSnippets-ConfigurationusingSpringorOSGi/Blueprint"/}}Configuration using Spring or OSGi/Blueprint ===
25 25  
26 26  If you are using OSGi with Blueprint or Spring to set up your project, you can configure a SchemaManager instance by adding the following to your blueprint {{code language="none"}}services.xml{{/code}} (or Spring configuration file):
27 27  
... ... @@ -33,7 +33,7 @@
33 33  </bp:reference>
34 34   
35 35  <bp:bean id="sqlDialect" factory-ref="dialectFactory" factory-method="newDialect">
36 -<bp:argument> <!-- Pass JDBC URL as an argument -->
87 +<bp:argument ref="jdbcUrl"><!-- bean jdbcUrl specified above -->
37 37  </bp:argument>
38 38  </bp:bean>
39 39   
... ... @@ -41,28 +41,46 @@
41 41  <bp:property name="dialect" ref="sqlDialect">
42 42  </bp:property>
43 43  </bp:bean>
95 +
44 44   
97 +<bp:bean id="initialSchema" class="foo.schema.InitialSchema"></bp:bean>
98
45 45  <bp:bean id="databaseSetup" class="org.clazzes.jdbc2xml.schema.SchemaManager" init-method="start">
46 46  <bp:property name="dataSource" ref="dataSource"></bp:property>
47 47  <bp:property name="schemaEngine" ref="schemaEngine"></bp:property>
102 + <!-- optional but recommended: special name for schema history table: -->
103 + <bp:property name="versionHistoryTable" value="MYLIB_SCHEMA_HISTORY"/>
104 + <!-- optional but recommended: explicit first version -->
48 48  <bp:property name="baseVersion" value="0.1.00" />
49 49  <bp:property name="baseTables">
50 -<!-- Add List of TableDefinitions here (see below) -->
107 +<!-- List of TableDefinitions here (see below), typical: -->
108 + <bp:bean factory-ref="initialSchema" factory-method="getSchema" />
51 51  </bp:property>
110 + <!-- Add Update-Snippets here, example for updates from 0.1.00 to 0.1.01 and on to 0.2.00
52 52  <bp:property name="upateSnippets">
53 -<!-- Add Update-Snippets here -->
112 +<bp:map>
113 + <bp:entry key="0.1.00" value="foo.schema.SchemaUpdate_0_1_01"></bp:entry>
114 + <bp:entry key="0.1.01" value="foo.schema.SchemaUpdate_0_2_00"></bp:entry>
115 +</bp:map>
54 54  </bp:property>
117 + -->
55 55  </bp:bean>
56 56  {{/code}}
57 57  
58 -By default, JDBC2XML provides an implementation of IDialectFactory and ISchemaEngineFactory as an OSGi service or via ServiceRegistry lookup for Spring.
121 +By default, JDBC2XML provides an implementation of IDialectFactory and ISchemaEngineFactory as an OSGi service or via ServiceRegistry for Spring.
59 59  
60 60  = {{id name="HowTocreateandupdateDatabasesusingSchemaManagerandSchemaUpdateSnippets-Settingupaninitialdatabaseschema"/}}Setting up an initial database schema =
61 61  
62 -To create an initial database schema, you will need to provide SchemaManager with a list of TableInfo objects. The recommended way to do this is to provide a class in your project which creates this list in it's constructor and provides it through a getter. You can instantiate this class in your Spring/Blueprint config as a singleton, and feed the provided List to SchemaManager. An example of this class could look like this:
125 +=== {{id name="HowTocreateandupdateDatabasesusingSchemaManagerandSchemaUpdateSnippets-InitalSchema(InitialTableList)"/}}Inital Schema (Initial Table List) ===
63 63  
127 +To create an initial database schema, SchemaManager needs a list of TableInfo objects.
128 +
129 +The recommended strategy is to create an InitialSchema class providing this list through a getter.
130 +
131 +(% style="font-size: 10.0pt;line-height: 13.0pt;" %)This is an example:
132 +
64 64  {{code language="java"}}
65 -package org.clazzes.example.jdbc2xml;
134 +package foo.schema;
66 66  
67 67  import java.sql.Types;
68 68  import java.util.Arrays;
... ... @@ -73,40 +73,31 @@
73 73  import org.clazzes.jdbc2xml.schema.PrimaryKeyInfo;
74 74  import org.clazzes.jdbc2xml.schema.TableInfo;
75 75   
76 -public class TableDefinitions {
145 +public class InitialSchema {
77 77  
78 - // It is adviseable to provide the Strings used as names for tables and columns as constants, so they can be reused outside this object to build sql-statements
79 - public static final String TB_EXAMPLE_TABLE_NAME = "ADDRESSBOOK";
80 - public static final String COL_EXAMPLE_ID = "ID";
81 - public static final String COL_EXAMPLE_NAME = "NAME";
82 - public static final String COL_EXAMPLE_ADDRESS_REF = "ADDRESS";
83 - public static final String COL_EXAMPLE_BIRTHDAY = "BIRTHDAY";
84
85 - // ...
86
87 87   private List<TableInfo> setup;
88 88  
89 - public TableDefinitions() {
149 + public InitialSchema() {
90 90  // Create a table
91 -TableInfo exampleTable = new TableInfo(TB_EXAMPLE_TABLE_NAME);
151 +TableInfo exampleTable = new TableInfo(TableDefs.TABLENAME_ADDRESSBOOK);
92 92  exampleTable.setColumns(
93 93   Arrays.asList(new ColumnInfo[] {
94 -new ColumnInfo(COL_EXAMPLE_ID, Types.BIGINT, 20, null, false, null,true),
95 -new ColumnInfo(COL_EXAMPLE_NAME, Types.VARCHAR, 256, null, false, null),
96 -new ColumnInfo(COL_EXAMPLE_ADDRESS_REF, Types.BIGINT, 20, null, true, null),
97 -new ColumnInfo(COL_EXAMPLE_BIRTHDAY, Types.DATE, 12, null, false, null)
154 +new ColumnInfo(TableDefs.COL_ADDRESSBOOK_ID, Types.BIGINT, 20, null, false, null,true),
155 +new ColumnInfo(TableDefs.COL_ADDRESSBOOK_NAME, Types.VARCHAR, 256, null, false, null),
156 +new ColumnInfo(TableDefs.COL_ADDRESSBOOK_ADDRESS_REF, Types.BIGINT, 20, null, true, null),
157 +new ColumnInfo(TableDefs.COL_ADDRESSBOOK_BIRTHDAY, Types.DATE, 12, null, false, null)
98 98  }));
99 99   
100 -// Example for creating a foreign key reference
101 -exampleTable.setForeignKeys(Arrays.asList(new ForeignKeyInfo[] {
102 -new ForeignKeyInfo("FK_EXAMPLE_ADDRESS", COL_EXAMPLE_ADDRESS_REF, TB_ADDRESS, COL_ADDRESS_ID)
103 -}));
104
105 105  // Example for creating a primary key
106 106  exampleTable.setPrimaryKey(
107 -new PrimaryKeyInfo("PK_EXAMPLE", COL_EXAMPLE_ID)
162 +new PrimaryKeyInfo("PK_EXAMPLE", COL_ADDRESSBOOK_ID)
108 108  );
109 109  
165 +// Example for creating a foreign key reference
166 +exampleTable.setForeignKeys(Arrays.asList(new ForeignKeyInfo[] {
167 +new ForeignKeyInfo("FK_EXAMPLE_ADDRESS", TableDefs.COL_ADDRESSBOOK_ADDRESS_REF, TableDefs.TABLENAME_ADDRESSES, TableDefs.COL_ADDRESS_ID)
168 +}));
169
110 110  // ...
111 111   
112 112  this.setup = Arrays.asList(
... ... @@ -116,23 +116,56 @@
116 116  
117 117   }
118 118    
119 - public List<TableInfo> getSetup() {
120 -return this.setup;
179 + public List<TableInfo> getSchema() {
180 +return this.schema;
121 121   }
122 122  
123 123  }
124 124  {{/code}}
125 125  
126 -You must inject {{code language="none"}}TableDefinitions.getSetup(){{/code}} into {{code language="none"}}SchemaManager.setBaseTables(){{/code}} before calling {{code language="none"}}SchemaManager.start(){{/code}}.
186 +=== {{id name="HowTocreateandupdateDatabasesusingSchemaManagerandSchemaUpdateSnippets-TableDefs,acentralplacefortableandcolumnnames"/}}TableDefs, a central place for table and column names ===
127 127  
188 +You may have notice the usage of {{code language="none"}}TableDefs.*{{/code}} members.
189 +
190 +Table and column names should never be re-typed everywhere as literals, it is highly recommended to use constants.
191 +
192 +Putting these constants in a dedicated class, say {{code language="none"}}TableDef{{/code}}, allows to use this as an easily accessible list of all tables and columns in the database.
193 +
194 +This is an example:
195 +
196 +{{code language="java"}}
197 +package foo.schema;
198 +
199 +public class TableDefs {
200 +
201 + // It is adviseable to provide the Strings used as names for tables and columns as constants,
202 + // so they can be reused savely to construct SQL statements
203
204 + // 0.1.00
205 + public static final String TABLENAME_ADDRESSBOOK = "ADDRESSBOOK";
206 + public static final String COL_ADDRESSBOOK_ID = "ID";
207 + public static final String COL_ADDRESSBOOK_NAME = "NAME";
208 + public static final String COL_ADDRESSBOOK_ADDRESS_REF = "ADDRESS";
209 + public static final String COL_ADDRESSBOOK_BIRTHDAY = "BIRTHDAY";
210 + // 0.1.01
211 +public static final String COL_ADDRESSBOOK_GENDER = "GENDER";
212
213 +}
214 +{{/code}}
215 +
216 +=== {{id name="HowTocreateandupdateDatabasesusingSchemaManagerandSchemaUpdateSnippets-Triggeringthecreationoftheinitialschema"/}}Triggering the creation of the initial schema ===
217 +
218 +(% style="font-size: 10.0pt;line-height: 13.0pt;" %)To trigger the creation of the initial schema when coming across an empty database, (% style="font-size: 10.0pt;line-height: 13.0pt;" %){{code language="none"}}InitialSchema.getSchema(){{/code}} has to be injected into (% style="font-size: 10.0pt;line-height: 13.0pt;" %){{code language="none"}}SchemaManager.setBaseTables(){{/code}} before calling (% style="font-size: 10.0pt;line-height: 13.0pt;" %){{code language="none"}}SchemaManager.start(){{/code}}.
219 +
128 128  Using Blueprint/Spring, you can do this by inserting the following snippet in the bean definition for SchemaManager:
129 129  
130 130  {{code language="html/xml"}}
131 -<!-- SchemaManager bean definition starts here ... -->
223 +<bp:bean id="initialSchema" class="foo.schema.InitialSchema"></bp:bean>
224
132 132  <bp:property name="baseTables">
133 -<bp:bean factory-ref="tableDefinitions" factory-method="getSetup" />
226 +<bp:bean factory-ref="initialSchema" factory-method="getSchema" />
134 134  </bp:property>
135 -<!-- ... and continues here -->
228 +
136 136  {{/code}}
137 137  
138 138  = {{id name="HowTocreateandupdateDatabasesusingSchemaManagerandSchemaUpdateSnippets-UpdatingadatabaseschemawithISchemaUpdateSnippet"/}}Updating a database schema with ISchemaUpdateSnippet =
... ... @@ -142,7 +142,7 @@
142 142  An example for an implementation of a schema update snippet could look like this:
143 143  
144 144  {{code language="java"}}
145 -package org.clazzes.example.jdbc2xml.updates;
238 +package foo.schema;
146 146  
147 147  import java.sql.SQLException;
148 148  import java.sql.Types;
... ... @@ -153,15 +153,11 @@
153 153  import org.clazzes.jdbc2xml.schema.PrimaryKeyInfo;
154 154  import org.clazzes.jdbc2xml.schema.TableInfo;
155 155  
156 -public class SchemaUpdate0_1_01 implements ISchemaUpdateSnippet {
249 +public class SchemaUpdate_0_1_01 implements ISchemaUpdateSnippet {
157 157   
158 158  // This is only accessed through the getter
159 159  private static final String TARGET_VERSION = "0.1.01";
160 160   
161 -// Here it is also adviseable to define constants for reuse in statements.
162 -public static final String COL_EXAMPLE_GENDER = "GENDER";
163 -
164 -
165 165  @Override
166 166  public String getTargetVersion() {
167 167  return TARGET_VERSION;
... ... @@ -169,13 +169,13 @@
169 169  
170 170  @Override
171 171  public String getUpdateComment() {
172 -return "Adding column "+COL_EXAMPLE_GENDER+" to table "+TableDefinitions.TB_EXAMPLE_TABLE_NAME+".";
261 +return "Adding column "+TableDefs.COL_ADDRESSBOOK_GENDER+" to table "+TableDefs.TABLENAME_ADDRESSBOOK+".";
173 173  }
174 174  
175 175  @Override
176 176  public void performUpdate(ISchemaEngine schemaEngine) throws SQLException {
177 -TableInfo ti = schemaEngine.fetchTableInfo(TableDefinitions.TB_EXAMPLE_TABLE_NAME, null);
178 - schemaEngine.addColumn(ti, new ColumnInfo(COL_EXAMPLE_GENDER, Types.VARCHAR, 1, null, true, null));
266 +TableInfo ti = schemaEngine.fetchTableInfo(TableDefs.TABLENAME_ADDRESSBOOK, null);
267 +schemaEngine.addColumn(ti, new ColumnInfo(TableDefs.COL_ADDRESSBOOK_GENDER, Types.VARCHAR, 1, null, true, null));
179 179  }
180 180  }
181 181  
... ... @@ -182,7 +182,7 @@
182 182  
183 183  {{/code}}
184 184  
185 -The return values of {{code language="none"}}ISchemaUpdateSnippet.getTargetVersion(){{/code}} and {{code language="none"}}ISchemaUpdateSnippet.getUpdateComment(){{/code}} are written to the {{code language="none"}}SCHEMA_HISTORY{{/code}} table. The update itself is performed in {{code language="none"}}ISchemaUpdateSnippet.performUpdate(){{/code}}. In the above example, it adds a column called {{code language="none"}}GENDER{{/code}} to the example table created by the TableDefinitions class above.
274 +The return values of {{code language="none"}}ISchemaUpdateSnippet.getTargetVersion(){{/code}} and {{code language="none"}}ISchemaUpdateSnippet.getUpdateComment(){{/code}} are written to the {{code language="none"}}SCHEMA_HISTORY{{/code}} table. The update itself is performed in {{code language="none"}}ISchemaUpdateSnippet.performUpdate(){{/code}}. In the above example, it adds a column called {{code language="none"}}GENDER{{/code}} to the ADDRESSBOOK table created via the InitialSchema class above.
186 186  
187 187  To add an entire table you would use the {{code language="none"}}ISchemaEngine.createTable(){{/code}} method, like this:
188 188  
... ... @@ -191,12 +191,12 @@
191 191  public void performUpdate(ISchemaEngine schemaEngine) throws SQLException {
192 192   TableInfo tiGroup = new TableInfo(TB_GROUP);
193 193   tiGroup.setColumns(Arrays.asList(new ColumnInfo[] {
194 - new ColumnInfo(TableDefinitions.COL_ID, Types.VARCHAR, 36, null, false, null),
195 - new ColumnInfo(TableDefinitions.COL_NAME, Types.VARCHAR, 100, null, false, null),
196 - new ColumnInfo(TableDefinitions.COL_DESCRIPTION, Types.VARCHAR, 512, null, true, null)
283 + new ColumnInfo(TableDefs.COL_ID, Types.VARCHAR, 36, null, false, null),
284 + new ColumnInfo(TableDefs.COL_NAME, Types.VARCHAR, 100, null, false, null),
285 + new ColumnInfo(TableDefs.COL_DESCRIPTION, Types.VARCHAR, 512, null, true, null)
197 197   }));
198 - tiGroup.setPrimaryKey(new PrimaryKeyInfo(PK_GROUP, TableDefinitions.COL_ID));
199 - tiGroup.setIndices(Arrays.asList(new IndexInfo(IDX_GROUP_01, TableDefinitions.COL_NAME, true, null)));
287 + tiGroup.setPrimaryKey(new PrimaryKeyInfo(PK_GROUP, TableDefs.COL_ID));
288 + tiGroup.setIndices(Arrays.asList(new IndexInfo(IDX_GROUP_01, TableDefs.COL_NAME, true, null)));
200 200  
201 201  schemaEngine.createTable(tiGroup, true);
202 202  }
... ... @@ -207,7 +207,7 @@
207 207  {{code language="java"}}
208 208  @Override
209 209  public void performUpdate(ISchemaEngine schemaEngine) throws SQLException {
210 - String sql = "UPDATE "+TableDefinitions.TB_EXAMPLE_TABLE_NAME+" SET "+TableDefinitions.COL_EXAMPLE_NAME+"=?";
299 + String sql = "UPDATE "+TableDefs.TB_EXAMPLE_TABLE_NAME+" SET "+TableDefs.COL_EXAMPLE_NAME+"=?";
211 211  
212 212   PreparedStatement ps = schemaEngine.getConnection().prepareStatement(sql);
213 213  
... ... @@ -230,14 +230,48 @@
230 230  <!-- ... and continues here -->
231 231  {{/code}}
232 232  
233 -
322 += {{id name="HowTocreateandupdateDatabasesusingSchemaManagerandSchemaUpdateSnippets-SchemaMaintainanceStrategies"/}}Schema Maintainance Strategies =
234 234  
235 -
324 +The JDBC2XML Schema management tools allow for 2 different strategies:
236 236  
237 -
326 +=== {{id name="HowTocreateandupdateDatabasesusingSchemaManagerandSchemaUpdateSnippets-Frozen(Initial)TableList"/}}Frozen (% style="font-size: 14.0pt;" %)(Initial) Table List(%%) ===
238 238  
239 -
328 +The legacy strategy is:
240 240  
241 -
330 +(% style="list-style-type: square;" %)
331 +* At the start of a project, create and use {{code language="none"}}InitalSchema.java{{/code}}
332 +* After the first commit, {{code language="none"}}InitalSchema{{/code}} are considered frozen, all changes go into {{code language="none"}}SchemaUpdates{{/code}}, up to one update per source code commit
242 242  
243 -
334 +Advantage: Rock solid.
335 +
336 +Disadvantage: No place to look for the complete and exact current scheme, except actual databases. {{code language="none"}}TableDefs.java{{/code}} provide some information, but may become confusing in the long term.
337 +
338 +=== {{id name="HowTocreateandupdateDatabasesusingSchemaManagerandSchemaUpdateSnippets-Possiblebutdangerous:Evolving(Initial)TableList"/}}Possible but dangerous: Evolving (Initial) Table List ===
339 +
340 +To keep the (Initial) Schema up do date, one might use this strategy:
341 +
342 +(% style="list-style-type: square;" %)
343 +* keep the {{code language="none"}}InitalSchema{{/code}} up to date, so an empty database always gets the current scheme in one shot
344 +* {{code language="none"}}SchemaUpdates{{/code}} are only applied to existing databases
345 +
346 +Advantage: Immediate overview over exact current scheme.
347 +
348 +Disadvantage: Very real danger of messing something up, because
349 +
350 +(% style="list-style-type: square;" %)
351 +* schema updates have to be coded in 2 different places in 2 different ways
352 +* the bean definition has to be maintained in 2 places but just 1
353 +
354 +Conclusion: **DO NOT DO THIS**. This strategy may be ok in very early stages, but at some point it has to be
355 +
356 +=== {{id name="HowTocreateandupdateDatabasesusingSchemaManagerandSchemaUpdateSnippets-Recommendation:FreezeInitialTableDefinitionnotlaterthanthefirstReleaseCandidate(RC)"/}}(% style="font-size: 14.0pt;" %)Recommendation: Freeze Initial Table Definition not later than the first Release Candidate (RC)(%%) ===
357 +
358 +It may be ok to start a new project using a fast changing (% style="font-size: 10.0pt;line-height: 13.0pt;" %)(Initial) Table List.
359 +
360 +(% style="font-size: 10.0pt;line-height: 13.0pt;" %)But, please, freeze it at some point. Once the first test server is setup up, internally or at a friendly customer, the Frozen Initial Table List Strategy is the only valid one!
361 +
362 += {{id name="HowTocreateandupdateDatabasesusingSchemaManagerandSchemaUpdateSnippets-RealworldExample"/}}Real world Example =
363 +
364 +This HowTo is currently evolving while an additional developer gets acostumed to the SchemaEngine, for developing [[SDS' org.clazzes.sds.impl.schema package>>url:http://svn.clazzes.org/svn/sds/trunk/sds.impl/src/main/java/org/clazzes/sds/impl/schema||style="font-size: 10.0pt;line-height: 13.0pt;" shape="rect"]](% style="font-size: 10.0pt;line-height: 13.0pt;" %) which is **work in progress**!
365 +
366 +(% style="font-size: 10.0pt;line-height: 13.0pt;" %)\\
Confluence.Code.ConfluencePageClass[0]
Id
... ... @@ -1,1 +1,1 @@
1 -656821
1 +656790
URL
... ... @@ -1,1 +1,1 @@
1 -https://clazzes.atlassian.net/wiki/spaces/JDBC2XML/pages/656821/How To create and update Databases using SchemaManager and SchemaUpdateSnippets
1 +https://clazzes.atlassian.net/wiki/spaces/JDBC2XML/pages/656790/How To create and update Databases using SchemaManager and SchemaUpdateSnippets