function hook_tripal_get_schema_name_alter

2.x hook_tripal_get_schema_name_alter($schema_name, $context)

Alter the name of the schema housing Chado and/or Drupal.

This example implementation shows a solution for the case where your chado database was well established in the "public" schema and you added Drupal later in a "drupal" schema. Please note that this has not been tested and while we can ensure that Tripal will work as expected, we have no control over whether Drupal is compatible with not being in the public schema. That's why we recommened the organization we have (ie: Chado in a "chado" schema and Drupal in the "public schema).


$schema_name: The current name of the schema as known by Tripal. This is likely the default set in tripal_get_schema_name() but in the case of multiple alter hooks, it might be different.

$context: This is an array of items to provide context.

  • schema: this is the schema that was passed to tripal_get_schema_name() and will be either "chado" or "drupal". This should be used to determine you are changing the name of the correct schema.

Related topics

1 invocation of hook_tripal_get_schema_name_alter()
tripal_get_schema_name in tripal_core/api/
Retrieve the name of the PostgreSQL schema housing Chado or Drupal.


tripal_core/api/, line 1847
Provides an API for querying of chado including inserting, updating, deleting and selecting from chado.


function hook_tripal_get_schema_name_alter($schema_name, $context) {

  // First we check which schema was passed to chado_get_schema().
  // Notice that we do not use $schema_name since it may already have
  // been altered by another module.
  if ($context['schema'] == 'chado') {
    $schema_name = 'public';
  // Notice that we use elseif to capture the second case rather than else. This
  // avoids the assumption that there is only one chado and one drupal schema.
  elseif ($context['schema'] == 'drupal') {
    $schema_name = 'drupal';