This document describes the DBInit and DBMigrate tool which is available since Intershop version 7.4. DBPrepare combines both tools in one and is available since 7.10.14.0. DBPrepare is using the declaration files of dbinit and dbmigrate.
Goals
The DBInit is a tool for initially creating the database schema objects and for preparing the database content of one or more cartridges. DBInit is not designed to migrate the database content and structure.
The DBMigrate tool is used to migrate the data and the database structure of an Intershop installation from defined former releases to an installed current release. It defines one global migration process, which can be executed on different environments. DBMigrate reuses some recurring migration steps (e.g., table creation), supports different development teams to create their own migration processes, and can minimize the effort to upgrade the development environment.
Documentation
This glossary describes the terms in this concept:
| Term | Description |
|---|---|
Cartridge | From a developer's perspective, a code container for implementation artifacts like templates, pipelines, Java code etc. that provide business logic or technical functionality to Intershop 7. From a system administrator's perspective, a type of deployment component for implementation artifacts that provide business logic or technical functionality to Intershop 7. |
Preparer | A preparer implements a database initialization or migration processor. The preparer can be processed by |
There are three processing phases in the DBInit and DBMigrate tools with the following processing order:
For additional information about the processing phases, see also the section on DBInit below.
Each phase loops through the list of cartridges. See also the DBInit description for the property cartridges.dbinit within cartridgelist.properties.
Each cartridge executes the preparers defined in the version-independent properties file(s) and in the version-specific properties file(s) (DBMigrate only).
DBInitThe following picture illustrates this processing behavior for DBInit:
List of cartridges:
cartridges.dbinit = Cartridge_1 Cartridge_2 ... Cartridge_nCartridge-specific preparer:
[pre.|post.]ClassN = Preparer [params]N - floating point number support, >= 0DBMigrateThe following picture illustrates this processing behavior for DBMigrate:
List of cartridges:
cartridges.dbinit = Cartridge_1 Cartridge_2 ... Cartridge_nCartridge-specific preparer:
[pre.|post.]ClassN = Preparer [params]N - floating point number support , >= 0Migration Path:
The order of the migration files is calculated from the version part of the file name:
Version_1, Version_2, ... Version_n string should map to the corresponding file nameDBInit
The list of cartridges to be processed by the DBInit and DBMigrate tools is specified in IS_SHARE/system/cartridges/cartridgelist.properties. The property name is specified by cartridges.dbinit. The supported value type is a space-separated list of cartridges.
Syntax for cartridges.dbinit in cartridgelist.properties:
cartridges.dbinit = cartridge1 cartridge2 ...
The DBInit process is configured using dbinit.properties files that exist for each cartridge at the location staticfiles/cartridge/dbinit.properties.
The file follows the standard Java properties file format. It contains a list of preparers that must be invoked during the DBInit process.
Each preparer is defined by an artificial property key with name Class, which is followed by a number. The number indicates the order in which the preparers will be called.
In addition, there are three preparer phases:
Phase | Property Key Prefix |
|---|---|
Pre-processing |
|
Main-processing |
|
Post-processing |
|
Syntax for the preparers in dbinit.properties:
[pre|post.]ClassN = cartridgePackage.prepareName [parameter1 parameter2 ...]
N - positive floating point number, example N = {0.0, ... 0.5, 0.75, 1, 2, 3, 3.5, ..., n}
n - largest positive finite floating point value, see java Double.MAX_VALUE
The currently known and used DBInit preparer parameters include:
The location patterns for preparer input files are:
Java properties:
Example of DBInit preparer input file for <type_of_data> : job, locking, organization, preference, ..., user, ...
SQL scripts:
The DBInit process stores all currently configured DBMigrate preparer steps from all migration*.properties files for each processed cartridge. This is done to prevent the execution of these DBMigrate steps after a DBInit.
DBMigrate
DBMigrate saves fine-grained migration steps with unique keys rather than the last migrated version of a cartridge. This approach allows the exact calculation of migration steps for a given migration path and avoids that newer database changes of older maintenance releases are never executed in newer migration operations.
The version based migration step processing works as follows:
The unique key for a preparation step consists of:
cartridgeUUID- The cartridge uuid within for the preparation step.ID- The property key of the preparation step, [pre|post.]ClassN.version- The version for the preparation step, e.g.: 7.4.3.0 or n/a.type- The preparation type, known types dbmigrate or dbinit.Additional -classic command line parameters support functionality for:
The migration path is calculated for each cartridge based on the version of the migration-to-<version>.properties files. The version supports up to 4 decimal parts (a.b.c.d).
The global migration properties are stored in:
This file defines the intershop.migration.DropTables = [true|false], a global property that specifies whether old database tables should be dropped during the migration.
After DBInit and DBMigrate have run, the last entry of the migration path for each cartridge is committed to the database table CartridgeInformation into the column MigrationVersion.
Migrated Intershop installation to 7.4.3.0 is stored cartridge-specific within CartridgeInformation:
UUID | ... | InternalName | ... | MigrationVersion | ... |
|---|---|---|---|---|---|
| core |
| |||
| bc_foundation |
| |||
... | ... |
|
Migration steps for an Intershop cartridge <example> with the following starting situation:
Migration preparation steps stored within database for cartridge <example> during previous migration to 7.4.3.0:
Property Key | Version | Preparation Class | Preparation Status |
|---|---|---|---|
pre.Class1 | 7.4.2.0 | ExecuteSQLScriptPreparer | SUCCESS |
Class1 | 7.4.3.0 | DropTable | SUCCESS |
Class2 | 7.4.3.0 | UpdateJobsPreparer | FAILURE |
post.Class1 | 7.4.3.0 | MigrateStagingEnvironment | SUCCESS |
Migration steps within file system for cartridge <example>:
Property Key | Version | Preparation Class |
|---|---|---|
pre.Class1 | 7.4.2.0 | ExecuteSQLScriptPreparer |
pre.Class1 | 7.4.4.0 | ExecuteSQLScriptPreparer |
Class1 | 7.4.3.0 | DropTable |
Class2 | 7.4.3.0 | UpdateJobsPreparer |
Class1 | 7.4.5.0 | DropTable |
post.Class1 | 7.4.3.0 | MigrateStagingEnvironment |
post.Class1 | 7.4.5.0 | DeletePreferenceDefinition |
Executed migration preparation steps for cartridge <example> during migration to 7.4.5.0:
Property Key | Version | Preparation Class | Why Execution | Preparation Status |
|---|---|---|---|---|
Class2 | 7.4.3.0 | UpdateJobsPreparer | previous failure | SUCCESS |
pre.Class1 | 7.4.4.0 | ExecuteSQLScriptPreparer | new step | SUCCESS |
Class1 | 7.4.5.0 | DropTable | new step | SUCCESS |
post.Class1 | 7.4.5.0 | DeletePreferenceDefinition | new step | SUCCESS |
The locations for various cartridge-specific migration properties are:
The file names are migration*.properties and contain pre.ClassN, ClassN and post.ClassN preparer, see also dbinit.properties syntax.
Generally, version-independent migration properties are used for:
The currently known and used DBMigrate preparer parameters include:
The location patterns for DBMigrate preparer input files are:
DBinit, the DBMigrate preparers use the original properties initially used by DBinit. Class1= .... dbmigrate .preparer.job.AddJobsPreparer root \ com/intershop/beehive/core/ dbinit /data/job/JobConfigurations.properties \ com/intershop/beehive/core/ dbmigrate /data/<version>/job/JobConfigurationUUIDs.properties
For all new files it is required to use the *Localization_en.properties naming. All old files with name *Information s _en.properties are deprecated.
ClassN = com.intershop.beehive.<>.dbinit.preparer.<>.PrepareFooBar \
com.intershop.beehive.<>.dbinit.data.<>.FooBar \
com.intershop.beehive.<>.dbinit.data.<>.FooBarLocalization
FooBarLocalization_en.properties FooBarLocalization_de.properties FooBarLocalization_<language>.properties
If no locale-specific bundle can be found an extra dbinit/dbmigrate fallback locale is used to get a suitable localized bundle before an unknown-localized base.properties resource bundle is used as last fallback.
The following property controls the dbinit/dbmigrate fallback locale handling, see IS_SHARE/system/config/cluster/dbinit.properties:
intershop.dbinit.fallbackLocale=en_US, default: feature enabled and value en_USDBMigrate preparers can be recalled several times. They call the migrate() method of each preparer. DBMigrate preparers should reside in the *.dbmigrate.* packages.
The Java documentation has to document the usage in migration properties files. The migration preparers are derived from the class com.intershop.beehive.core.dbinit.capi.Preparer.
DBMigrate processing. A replication environment does not support different UUIDs on semantically identical objects.SQLScriptPreparer does not allow ORA- errors during the execution of SQL scripts. Blind drops of tables, materialized views, etc. lead to failures.UpdateJobPreparer, DeleteJobsPreparer, AddJobsPreparerIS_HOME/bin/environment.bat.IS_HOME/tools/misc.ant uuid.Syntax:
ant uuid [-DamountUUID=number]
Example:
ant uuid -DamountUUID=2 createuuid: [echo] Generating an amount of 2 UUIDs... [java] UUID: 8rKsFt249DIAAAExssSBUPak [java] UUID: CKOsFt24gu8AAAExtMSBUPak
DBInit and Migration Preparer for DBMigrateTo find all currently available preparers (DBInit and DBMigrate), check the installed Java documentation of the Intershop server installation.
DBInit and DBMigrate preparers.DBInit and DBMigrate package naming is specified by com.intershop.*.<cartridge>.<dbinit|dbmigrate>.preparer.*.Example of core cartridge:
Package | Classes |
|---|---|
|
|
|
|
The execution of DBInit and DBMigrate supports the execution in a non-interactive console-based mode called classic mode.
The following property controls the further preparer execution if an error occurs, see IS_SHARE/system/config/cluster/dbinit.properties:
intershop.dbinit|dbmigrate.breakOnError=true|false, default falseThe optional command line parameters for DBInit and DBMigrate are:
Mode | Both | Only | Only | Default Value | Description |
|---|---|---|---|---|---|
Non-Interactive | breakOnError handling for dbinit/dbmigrate: Example: Success: bc_mvc:Class6 ...Preparer ...ms Failure: bc_mvc:7.1.0.0:Class10 ...Preparer ...ms Success: bc_preview_orm:Class1 ...Preparer ...ms | ||||
| -!,-classic | Classic mode, no beginning prompt to continue processing | ||||
-c=<KEYS>,--property-keys=<KEYS> | all | Comma-separated list of preparer property <KEYS> to execute | |||
-h,--h,-help,--help,-?,?,/help,/h,/? | Print this message | ||||
-i=<FLAG>,--move-indexes=<FLAG> | true | Move database indexes to a separate tablespace if <FLAG> is true | |||
-m=<FLAG>,--table-monitoring=<FLAG> | true | Enable the database table monitoring for optimization reasons if <FLAG> is true | |||
-t=<CARTRIDGES>,--cartridges=<CARTRIDGES> | all | Process the comma-separated <CARTRIDGES> list | |||
-v=<FLAG>,-verbose=<FLAG>,--verbose=<FLAG> | false | Display more information if <FLAG> is true | |||
--dry-run | Show only the preparation execution steps and do not execute any preparer | ||||
-is.share=<PATH> | The <PATH> location of shared directory | ||||
| --ddl=<FLAG> | false | Only perform ddl database preparation steps if <FLAG> is true | |||
| -cdb=<FLAG>,--clean-db=<FLAG> | no | A clean up is called before dbinit steps | |||
-r=<FLAG>,--recreate-tables=<FLAG> | true | Re-create database tables if <FLAG> is true | |||
--exec-id=<IDs> | Execution for a comma separated list of <IDs> | ||||
-b=<FLAG>,--database-backup=<FLAG> | true | Backup the database before migration processing if <FLAG> is true | |||
--dry-run-save | Like --dry-run but additional save preparation steps to database to avoid | ||||
--exclude-version-dependent | Suppress execution of version dependent preparer | ||||
--exclude-version-independent | Suppress execution of version independent preparer | ||||
--force-exec-all | Re-execution for all steps | ||||
--force-exec-id=<IDs> | Re-execution for a comma separated list of <IDs> | ||||
--force-exec-name=<NAMES> | Re-execution for a comma separated list of preparer <NAMES> | ||||
--force-exec-version=<VERSIONS> | Re-execution for a comma separated list of <VERSIONS> | ||||
--force-exec-prefix=<PREFIXES> | Re-execution for a comma separated list of <PREFIXES> |
DBInitThe content of the (version-independent) dbinit.properties files looks like this:
pre.Class1 = com.intershop.beehive.core.dbinit.preparer.database.DatabaseTablesPreparer
...
Class1 = com.intershop.beehive.core.dbinit.preparer.database.SQLScriptPreparer \
resources/core/dbinit/scripts/utctimestamp.sql
...
post.Class50 = com.intershop.beehive.core.dbinit.preparer.locking.RemoveAllProcesses
DBMigrateExample: The content of the migration*.properties files looks like this:
pre.Class0.5 = com.intershop.beehive.core.dbmigrate.preparer.database.DatabaseTablesPreparer
pre.Class1 = com.intershop.beehive.core.dbmigrate.preparer.database.BackupDatabasePreparer
...
Class1 = com.intershop.beehive.core.dbmigrate.preparer.database.DatabaseTablesPreparer
Class2 = com.intershop.beehive.core.dbmigrate.preparer.database.ExecuteSQLScriptPreparer \
resources/core/dbinit/scripts/spmainfile.ddl
Class3 = com.intershop.beehive.core.dbmigrate.preparer.database.DatabaseIndexesPreparer \
resources/core/dbinit/scripts/dbindex.ddl
Class4 = com.intershop.beehive.core.dbmigrate.preparer.database.DatabaseConstraintsPreparer \
resources/core/dbinit/scripts/dbconstraints.ddl
...
post.Class50 = com.intershop.beehive.core.dbmigrate.preparer.locking.ReleaseAllResources
Class1 = com.intershop.beehive.core.dbmigrate.preparer.job.AddJobsPreparer \
root \
com/intershop/beehive/core/dbinit/data/job/JobConfigurations.properties \
com/intershop/beehive/core/dbmigrate/data/7.3.0.0/job/JobConfigurationUUIDs.properties
Class2 = com.intershop.beehive.core.dbmigrate.preparer.job.UpdateJobsPreparer \
root \
com.intershop.beehive.core.dbinit.data.job.JobConfigurations
All log files reside in IS_SHARE/system/log. The general log files of preparers are:
- General log files: <loglevel>-*-migration|dbinit-<date>.log - SQL log files: <IS_SHARE>/system/log/dbmigrate|dbinit-sql/*/*.log
The main log file of DBInit and DBMigrate tool is:
- dbinit-*.log - migration-*.log
General Java debugging is possible with IS_HOME/bin/dbinit|dbmigrate[.bat|.sh]. Remove the REM or # before the debug setting, example:
SET DEBUG=-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=6666,suspend=n -Xint
DEBUG="-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=6666,suspend=n -Xint"
Example log files:
Startup DBInit (appserver mode DBInit)... Startup finished in 34s -------------------- pre-processing --------------------- Success: core:pre.Class1 DatabaseTablesPreparer 1169ms ... -------------------- main-processing -------------------- Success: core:Class1 SQLScriptPreparer [resources/core/dbinit/scripts/utctimestamp.sql] 194ms ... -------------------- post-processing -------------------- Success: core:post.Class2 StagingEnvironmentPreparer [all] 0ms ... -------------------- preparation summary ---------------- DBInit with 513 initialization steps (success: 513, failure: 0) finished in 1.037s
Startup DBMigrate (appserver mode DBMigrate)... Startup finished in 51s -------------------- pre-processing --------------------- Success: core:pre.Class0.5 DatabaseTablesPreparer 548ms Success: core:pre.Class1 BackupDatabasePreparer 12ms ... -------------------- main-processing -------------------- Success: core:Class1 DatabaseTablesPreparer 538ms Success: core:Class2 ExecuteSQLScriptPreparer [resources/core/dbinit/scripts/spmainfile.ddl,disableLogging] 334ms ... -------------------- post-processing -------------------- Success: core:7.3.2.0:post.Class1 MigrateStagingEnvironment 17447ms Success: core:post.Class50 ReleaseAllResources 3ms ... -------------------- preparation summary ---------------- Failure: bc_mvc:7.1.0.0:pre.Class2 ... Failure: bc_marketing:7.3.1.0:pre.Class1 .... ... DBMigrate with 446 executed (success: 434, failure: 12) and 0 skipped migration steps finished in 515s
Some preparers support and/or require properties files that contain additional information. Usually, several data sets can be entered in this file, which are then processed iteratively.
Data.1.id = Foo_ID Data.1.name = Foo Data.2.id = Bar_ID Data.2.name = Bar Data.3.id = FooBar_ID Data.3.name = FooBar
The implementation of the preparers is not consistent here. Some collect all data sets to determine the different data set groups (Data.<>), others work per count variable and abort if there is a gap in the data set indexing. In the second case, if Data.2 did not exist or was commented out, Data.3 would not be reached and processed.
Info
Starting from ICM version 7.10.35, preparers first collect the data sets and then process them. This allows numbers and ranges in the properties files to be omitted (or commented out) without affecting other data sets.
The information provided in the Knowledge Base may not be applicable to all systems and situations. Intershop Communications will not be liable to any party for any direct or indirect damages resulting from the use of the Customer Support section of the Intershop Corporate Website, including, without limitation, any lost profits, business interruption, loss of programs or other data on your information handling system.