Chapter 2. Extending the Schema

Michael Saffitz

Table of Contents

Creating New Objects in the Database
Adding New Columns to Existing Tables
Adding New Tables
Adding New Views
Updating GUS Version Objects
Updating Core.TableInfo
Rebuilding Objects

The GUS Schema may be extended by adding new columns to existing tables, or adding new tables and views. For the time being, adding new Schemata to GUS is not supported.

Important

Extensions to the GUS may interfere with your ability to upgrade to future releases of GUS.

Creating New Objects in the Database

The first step to extending the Schema is to create the objects within the database.

Adding New Columns to Existing Tables

When adding new columns to existing tables, it is important to maintain the existing order of the columns, and only add new columns between the existing columns and the housekeeping columns (eg before the modification_date column). For this reason, it will likely be necessary to rename the existing table; create the modified table; and then migrate the date from the existing table to the newly created table. As you perform this process, you should ensure that all constraints (including both "incoming" and "outgoing" foreign key constraints and primary key constraints) and that indexes on the original table are created and applied on the newly created table.

Adding New Tables

When creating new tables, it is important to include all housekeeping columns at the "end" of the definition in the proper order. All new tables should have a corresponding sequence created, with the naming convention of: TableSchemaName.TableName_SQ . All new tables must have a single column primary key constraint defined.

Adding New Views

Only views created as "subclass" views against an implementation table are supported. When creating new views, it is important to include all superclass columns in the view definition, including the housekeeping columns. Proper column ordering should be observed in the views.

Updating GUS Version Objects

If you've changed an existing GUS table, or wish to have GUS audit changes to your new tables and views, you must make the corresponding changes and/or additions to the version ("ver") tables and views.

Updating Core.TableInfo

GUS stores metadata for all tables and views in the Core.TableInfo table. Whenever you create a new table or view, you must add a corresponding row in this table. The column descriptions are:

Table 2.1. Core.TableInfo Description

Column NameDescription
table_idThe ID of this row, provided by the com Core.TableInfo_SQ sequence.
nameThe name of the table. The case used here will be used at object-generation time.
table_typeStandard or Version, depending on whether this is a normal table or a version table
primary_key_columnThe name of the primary key column
database_idThe id of the schema, found in Core.DatabaseInfo
is_versioned1 if the table has a corresponding version table. 0 otherwise.
is_view1 if the "table" is a subclass view. 0 otherwise.
view_on_table_idIf this "table" is a subclass view, the table id of the implementation table that this view is against.
superclass_table_idIf this "table" is a subclass view, the table id of the superclass view.
is_updatable1 if the table is read/write, 0 if it is read only.

Rebuilding Objects

After you have completed the steps above, you must rebuild your objects. First, use the command below to signal that your table definitions have changed:

$ touch $PROJECT_HOME/Schema/gus_schema.xml

Then, reinstall GUS:

$ build GUS install -append