How To Change The Size of a Column

From InfiniteERP Wiki
Jump to: navigation, search

Objective

The objective of this article is to show you how to change the size of a column inside the database. It enables the user to have a certain amount of flexibility within his/her database.

Recommended articles

Before reading this guide, it is necessary to have a proper understanding of Openbravo's Modularity concept and how to create and package a module,
as we take the knowledge from these articles as a given in this guide.

In case you are working with configuration scripts or templates on a regular basis, the following link to an article might be of interest to you, since it describes how to create a configuration script.

Execution Steps

In Openbravo you are able to change the size of a column. To achieve this you must follow the following steps:

  1. Create a template and set its status as "In Development".
  2. Modify the column size within the database with the "ALTER TABLE" SQL command.
IMPORTANT: The new value must be greater than the old one.<source lang = "sql">Postgres: ALTER TABLE <table_name> ALTER COLUMN <column_name> type <type>(<new_size>) Oracle: ALTER TABLE <table_name> MODIFY <column_name> <type>(<new_size>) </source>
  1. Update the new column size in the Application Dictionary. For this, we go to the "Tables and Columns" window, find the column definition and specify the new size there
  2. Export the database: "ant export.database" (with this you are exporting the template definitions)
  3. Export the configuration script: "ant export.config.script" (with this you are exporting the core changes into the template)
  4. Check the generated configuration script and verify that the change regarding the new column size appears in the first lines.
Bulbgraph.png   Note: As a final remark with great importance: If the column that has been modified is being used by a database function by giving its value to another variable for example, you must check that this variable has an equal or greater size (at least the size of the new modified column). Because if not, the process would fail. This means, if the variable's size wasn't enough to store the columns content, you have to modify the function as well, by adjusting the size of the variable in question and exporting this change into your template.

So please verify that your new column size does not affect you in any way (functions or triggers) working with your database.