Qore Schema Module Reference: Schema::AbstractSchema Class Reference

Qore Schema Module Reference 1.0

- Main Page
- Related Pages
- Namespaces
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Functions Variables Groups Pages
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
Schema::AbstractSchema Class Referenceabstract

the AbstractSchema class is a base class to assist with automatic schema management More...

Inheritance diagram for Schema::AbstractSchema:
[legend]

## Public Member Functions
int | align (bool force=False, int verbose=0)
| executes a schema alignment action on the database with the current schema template More...
private bool | checkDropSchema (bool force)
| this method returns True if the schema can be dropped
private bool | checkExistence ()
| returns True if the method can detect that DB objects defined in the schema exist in the database More...
private bool | checkFirstTimeInstall ()
| returns True if checkExistence() returns False
private bool | checkUpdateSchema (bool force, reference initial_schema_info)
| this method returns True if the schema can be updated
| constructor (AbstractDatasource n_ds, *string dts, *string its)
| creates the object from the arguments More...
private | doPostAlignment (Tables table_cache, bool first_time_install, *hash initial_schema_info)
| this method is called after schema structural alignment has been executed but before schema reference data management
private | doTable (AbstractTable table, list rows, int upsert_strategy, bool delete_others, int verbose, reference sh)
| this method is called to perform schema reference data managment on the given table with the given data
| drop (bool force=False, int verbose=0)
| executes a schema drop operation in the database
*hash | getColumnOptions ()
| returns column options More...
private *hash | getColumnOptionsImpl ()
| returns column options More...
*hash | getCreateOnlyReferenceData ()
| returns a hash of "create-only reference data", describing data that is written to the table when the table is created More...
private *hash | getCreateOnlyReferenceDataImpl ()
| returns a hash of "create-only reference data", describing data that is written to the table when the table is created More...
*hash | getCreationOptions ()
| returns schema creation options More...
AbstractDatabase | getDatabase ()
| returns the AbstractDatabase object used for the schema
AbstractDatasource | getDatasource ()
| returns the datasource used for the schema
*hash | getFunctions ()
| returns function definitions More...
private *hash | getFunctionsImpl ()
| returns function definitions More...
private *hash | getGenericOptionsImpl ()
| returns schema creation options More...
*hash | getIndexOptions ()
| returns index options More...
private *hash | getIndexOptionsImpl ()
| returns index options More...
*hash | getInsertOnlyReferenceData ()
| returns a hash of "create-only reference data", describing data that will only be inserted if missing, otherwise existing rows with changed data are left unchanged More...
private *hash | getInsertOnlyReferenceDataImpl ()
| returns a hash of "create-only reference data", describing data that will only be inserted if missing, otherwise existing rows with changed data are left unchanged More...
*hash | getMaterializedViews ()
| returns materialized view definitions More...
private *hash | getMaterializedViewsImpl ()
| returns materialized view definitions More...
string | getName ()
| returns the name of the schema
abstract private string | getNameImpl ()
| returns the version of the schema
*hash | getPackages ()
| returns (Oracle) package definitions More...
private *hash | getPackagesImpl ()
| returns (Oracle) package definitions More...
*hash | getProcedures ()
| returns stored procedure definitions More...
private *hash | getProceduresImpl ()
| returns stored procedure definitions More...
*hash | getReferenceDataHash ()
| returns a hash of "normal reference data", describing data that must appear in the target table, however additional rows are also acceptable More...
private *hash | getReferenceDataHashImpl ()
| returns a hash of "normal reference data", describing data that must appear in the target table, however additional rows are also acceptable More...
*hash | getSequences ()
| returns sequence definitions More...
private *hash | getSequencesImpl ()
| returns sequence definitions More...
*hash | getStrictReferenceDataHash ()
| returns a hash of "strict reference data", describing the only data that can appear in the target table More...
private *hash | getStrictReferenceDataHashImpl ()
| returns a hash of "strict reference data", describing the only data that can appear in the target table More...
*hash | getTables ()
| returns table definitions More...
private *hash | getTablesImpl ()
| returns table definitions More...
*hash | getTypes ()
| returns type definitions More...
private *hash | getTypesImpl ()
| returns type definitions More...
private int | getUpsertStrategy (bool first_time_install)
| this method is called to return the upsert strategy before schema reference data management
string | getVersion ()
| returns the version of the schema
abstract private string | getVersionImpl ()
| returns the version of the schema
| log (string fmt)
| outputs a log message More...
| logpf (string fmt)
| outputs a log message prefixed with the schema name More...
| logProgress (string str)
| outputs a log message without any newline More...
private | postDataActions (bool first_time_install)
| this method is called after schema reference data has been managed

## Static Public Member Functions
static hash | combineOptions (*hash h)
| combines option hashes into a single target option hash
static list | getRows (*softlist l)
| returns a list of hashes from a list of lists where the first list element in the top-level list is a list of column names, and subsequent lists are column values More...

## Private Attributes
*hash | all_options
| combined creation and column options
hash | callback_opts
| callback options plus all options
*hash | column_options
| column options, as provided by getColumnOptions()
*hash | creation_options
| creation options, as provided by getCreationOptions()
*string | data_ts
| explicit data tablespace name
SqlUtil::Database | db
| the Database object for the schema
string | drv
| the name of the database driver
AbstractDatasource | ds
| the datasource for the schema
*hash | index_options
| index options, as provided by getIndexOptions()
*string | index_ts
| explicit index tablespace name
code | info_callback
| the info callback for schema operations; can be used for explicit logging
string | name
| the name of the schema
hash | pure_callback_opts
| just callback options
hash | schema
| the schema template, as assembled from method callbacks providing schema element definitions
string | version
| the version of the schema

## Detailed Description

the AbstractSchema class is a base class to assist with automatic schema management

This class allows the following actions to be performed:

- schema creation, upgrades, and downgrades (through schema alignment)
- schema deletion / dropping

This class does not provide for any intelligence based on the schema template's version and a schema version string stored in the schema itself; this is provided instead by the AbstractVersionedSchema class.

The following abstract methods must be re-implemented in subclasses to define basic schema attributes:

- getNameImpl(): returns the schema name
- getVersionImpl(): returns the schema version

The following methods should be re-implemented in subclasses to define schema definitions from which DDL will be generated::

- getTablesImpl(): returns table definitions
- getSequencesImpl(): returns sequence definitions
- getTypesImpl(): returns type definitions
- getFunctionsImpl(): returns function definitions
- getProceduresImpl(): returns procedure definitions
- getPackagesImpl(): returns (Oracle) package definitions
- getMaterializedViewsImpl(): returns materialized view definitions

The following methods should be re-implemented in subclasses to define schema creation options to affect the generated DDL:

- getIndexOptionsImpl(): returns index options
- getColumnOptionsImpl(): returns column options
- getGenericOptionsImpl(): returns generic options

The following methods should be re-implemented in subclasses to define schema reference data:

- getStrictReferenceDataHashImpl(): returns a hash of "strict reference data", describing the only data that can appear in the target table
- getReferenceDataHashImpl(): returns a hash of "normal reference data", describing data that must appear in the target table, however additional rows are also acceptable
- getCreateOnlyReferenceDataImpl(): returns a hash of "create-only reference data", describing data that is written to the table when the table is created
- getInsertOnlyReferenceDataImpl(): returns a hash of "create-only reference data", describing data that will only be inserted if missing, otherwise existing rows with changed data are left unchanged

## Member Function Documentation

int Schema::AbstractSchema::align | ( | bool | force = `False`,
|  | int | verbose = `0`
| ) |  |

executes a schema alignment action on the database with the current schema template

this causes the database to be aligned with the schema template, which will result in:

- the schema being created in an empty schema
- the schema being upgraded if an older version of the schema exists in the database
- the schema being downgraded if a newer version of the schema exists in the database

Note
  if other database objects not belonging to the schema already exist in the given database, they will be dropped

private bool Schema::AbstractSchema::checkExistence | ( |  | ) |

returns True if the method can detect that DB objects defined in the schema exist in the database

Currently this method checks if at least one of the first tables, sequences, functions, or procedures defined in the schema template exists. If so, this method returns True, otherwise it returns False

Schema::AbstractSchema::constructor | ( | AbstractDatasource | n_ds,
|  | *string | dts,
|  | *string | its
| ) |  |

creates the object from the arguments

Parameters

  n_ds | the datasource for the schema
  dts | an optional data tablespace name for the schema
  its | an optional index tablespace name for the schema

*hash Schema::AbstractSchema::getColumnOptions | ( |  | ) |

returns column options

this function wraps getColumnOptionsImpl(); for forwards-compatibility, do not override this method in subclasses, instead re-implement getColumnOptionsImpl()

private *hash Schema::AbstractSchema::getColumnOptionsImpl | ( |  | ) |

returns column options

the default behavior of this method is to return NOTHING, reimplement in subclasses to return custom options

*hash Schema::AbstractSchema::getCreateOnlyReferenceData | ( |  | ) |

returns a hash of "create-only reference data", describing data that is written to the table when the table is created

this function wraps (); for forwards-compatibility, do not override this method in subclasses, instead re-implement ()

private *hash Schema::AbstractSchema::getCreateOnlyReferenceDataImpl | ( |  | ) |

returns a hash of "create-only reference data", describing data that is written to the table when the table is created

the default behavior of this method is to return NOTHING, reimplement in subclasses to return custom configuration

*hash Schema::AbstractSchema::getCreationOptions | ( |  | ) |

returns schema creation options

this function wraps getGenericOptionsImpl() and getIndexOptionsImpl() and sets the data and index tablespace names as creation options automatically if set in the constructor() if not already set

*hash Schema::AbstractSchema::getFunctions | ( |  | ) |

returns function definitions

this function wraps getFunctionsImpl(); for forwards-compatibility, do not override this method in subclasses, instead re-implement getFunctionsImpl()

private *hash Schema::AbstractSchema::getFunctionsImpl | ( |  | ) |

returns function definitions

the default behavior of this method is to return NOTHING, reimplement in subclasses to return custom configuration

private *hash Schema::AbstractSchema::getGenericOptionsImpl | ( |  | ) |

returns schema creation options

the default behavior of this method is to return NOTHING, reimplement in subclasses to return custom options

*hash Schema::AbstractSchema::getIndexOptions | ( |  | ) |

returns index options

this function wraps getIndexOptionsImpl() and sets the index tablespace name as an index option automatically if set in the constructor() if not already set

private *hash Schema::AbstractSchema::getIndexOptionsImpl | ( |  | ) |

returns index options

the default behavior of this method is to return NOTHING, reimplement in subclasses to return custom options

*hash Schema::AbstractSchema::getInsertOnlyReferenceData | ( |  | ) |

returns a hash of "create-only reference data", describing data that will only be inserted if missing, otherwise existing rows with changed data are left unchanged

this function wraps (); for forwards-compatibility, do not override this method in subclasses, instead re-implement ()

private *hash Schema::AbstractSchema::getInsertOnlyReferenceDataImpl | ( |  | ) |

returns a hash of "create-only reference data", describing data that will only be inserted if missing, otherwise existing rows with changed data are left unchanged

the default behavior of this method is to return NOTHING, reimplement in subclasses to return custom configuration

*hash Schema::AbstractSchema::getMaterializedViews | ( |  | ) |

returns materialized view definitions

this function wraps getMaterializedViewsImpl(); for forwards-compatibility, do not override this method in subclasses, instead re-implement getMaterializedViewsImpl()

private *hash Schema::AbstractSchema::getMaterializedViewsImpl | ( |  | ) |

returns materialized view definitions

the default behavior of this method is to return NOTHING, reimplement in subclasses to return custom configuration

*hash Schema::AbstractSchema::getPackages | ( |  | ) |

returns (Oracle) package definitions

this function wraps getPackagesImpl(); for forwards-compatibility, do not override this method in subclasses, instead re-implement getPackagesImpl()

private *hash Schema::AbstractSchema::getPackagesImpl | ( |  | ) |

returns (Oracle) package definitions

the default behavior of this method is to return NOTHING, reimplement in subclasses to return custom configuration

*hash Schema::AbstractSchema::getProcedures | ( |  | ) |

returns stored procedure definitions

this function wraps getProceduresImpl(); for forwards-compatibility, do not override this method in subclasses, instead re-implement getProceduresImpl()

private *hash Schema::AbstractSchema::getProceduresImpl | ( |  | ) |

returns stored procedure definitions

the default behavior of this method is to return NOTHING, reimplement in subclasses to return custom configuration

*hash Schema::AbstractSchema::getReferenceDataHash | ( |  | ) |

returns a hash of "normal reference data", describing data that must appear in the target table, however additional rows are also acceptable

this function wraps getReferenceDataHashImpl(); for forwards-compatibility, do not override this method in subclasses, instead re-implement getReferenceDataHashImpl()

private *hash Schema::AbstractSchema::getReferenceDataHashImpl | ( |  | ) |

returns a hash of "normal reference data", describing data that must appear in the target table, however additional rows are also acceptable

the default behavior of this method is to return NOTHING, reimplement in subclasses to return custom configuration

static list Schema::AbstractSchema::getRows | ( | *softlist | l | ) |
| static

returns a list of hashes from a list of lists where the first list element in the top-level list is a list of column names, and subsequent lists are column values

meant to be used to translate reference data lists into lists of hashes to be used for upserting in reference data tables during schema management

*hash Schema::AbstractSchema::getSequences | ( |  | ) |

returns sequence definitions

this function wraps getSequencesImpl(); for forwards-compatibility, do not override this method in subclasses, instead re-implement getSequencesImpl()

private *hash Schema::AbstractSchema::getSequencesImpl | ( |  | ) |

returns sequence definitions

the default behavior of this method is to return NOTHING, reimplement in subclasses to return custom configuration

*hash Schema::AbstractSchema::getStrictReferenceDataHash | ( |  | ) |

returns a hash of "strict reference data", describing the only data that can appear in the target table

this function wraps getStrictReferenceDataHashImpl(); for forwards-compatibility, do not override this method in subclasses, instead re-implement getStrictReferenceDataHashImpl()

private *hash Schema::AbstractSchema::getStrictReferenceDataHashImpl | ( |  | ) |

returns a hash of "strict reference data", describing the only data that can appear in the target table

the default behavior of this method is to return NOTHING, reimplement in subclasses to return custom configuration

*hash Schema::AbstractSchema::getTables | ( |  | ) |

returns table definitions

this function wraps getTablesImpl(); for forwards-compatibility, do not override this method in subclasses, instead re-implement getTablesImpl()

private *hash Schema::AbstractSchema::getTablesImpl | ( |  | ) |

returns table definitions

the default behavior of this method is to return NOTHING, reimplement in subclasses to return custom configuration

*hash Schema::AbstractSchema::getTypes | ( |  | ) |

returns type definitions

this function wraps getTypesImpl(); for forwards-compatibility, do not override this method in subclasses, instead re-implement getTypesImpl()

private *hash Schema::AbstractSchema::getTypesImpl | ( |  | ) |

returns type definitions

the default behavior of this method is to return NOTHING, reimplement in subclasses to return custom configuration

Schema::AbstractSchema::log | ( | string | fmt | ) |

outputs a log message

the log string is output with a following newline, and the terminal I/O is flushed

Schema::AbstractSchema::logpf | ( | string | fmt | ) |

outputs a log message prefixed with the schema name

the log string is output with a following newline, and the terminal I/O is flushed

Schema::AbstractSchema::logProgress | ( | string | str | ) |

outputs a log message without any newline

the terminal I/O is flushed as well