You may not need post-upgrade scripts in your release at all. But every decision to create one must always be made during development, at the time when you are conscious of making changes that could affect data upgrades on target machines. It is bad practice to leave these decisions until release time.
Avoid writing a post-upgrade script that does something that the create-tables script will automatically take care of. For example:
•If you add a new mandatory column and this column has a Default Value, then the "200.upg.rdbms.sql" create-tables script will automatically apply the default value to existing records. You do not need to write a script for this. In practice, typical use cases for post-upgrade scripts include new calculation rules and data migration:
New calculation rule
A post-upgrade script may be needed when you have new calculation rules on existing data. For example,
•If existing calculated data is calculated differently in the new application version, this new calculation may need to be applied to existing cases as well. However, it is often desirable in such cases that the new calculation is applied only to new cases, not to existing cases. •If you add a new mandatory column and this column must be set to the result of some calculation performed by a new constraint, you usually need a special script that applies the new constraint SQL to existing records. In these 2 use cases, the solution is often simply to copy the constraint SQL that does the calculation to your post-upgrade script.
Data migration
Sometimes, existing data must migrate to a different data structure. One example is that you split an old column PERSON.ADDRESS into PERSON.HOME_ADDRESS and PERSON.BILLING_ADDRESS and it was decided that each existing address must be preserved initially both as home address and as billing address. Another example is that you move a column (BANK_ACCOUNT) from a subtype (EMPLOYEE) to a supertype (PERSON) and it was decided that old "employee bankaccount numbers" must be preserved as "person bank account numbers".
|