Sometimes it’s necessary to execute additional scripts on the database. In ORCAS there are one-time skripts, which are scripts that are running (on any database schema) exactly once.
Rename column (with data)
Voraussetzung: In der Tabelle Items befinden sich nach wie vor Daten.
Now we want to rename the column description into descriptions.
First, the table definition must be adjusted accordingly:
Next run the build again with ant.
When in the build.xml the drop mode back is set to false, there is again an error message. Since ORCAS can not recognize that the column was only renamed, it’s trying to remove the column description and adds the new column descriptions. Therefore the drop mode is active and prevents data loss. If the table is empty, the changes would be carried out.
Since we do not want to lose our sample data, setting dropmode=true isn’t an alternative. Instead we can use an one-time script:
The script is saved in the folder skripte with any name. The table definiton from items corresponds already to the target scenario descriptions.
Now we can run ant.
The build was successful and another column is renamed. Important for this was that the script was executed before the tables were validated/created as described. Thus, the column was already named description s when it has been validated against the table definition.
Pre-skripts in the build.xml
That the script executed BEFORE the table definitions is controlled via the build.xml:
Here is also the folder scripts defined for our script.
the order of execution is set, therefore pre_scripts before build_tables.
How does one-time scripts work
Similar to Flyway and Liquibase, a table also provides in ORCAS that each script runs only once. In ORCAS_ORDERENTRY_ORCAS the corresponding table ORCAS_UPDATES is found. Here can be viewed when each script was run.