Skip to content

Instantly share code, notes, and snippets.

@laradevitt
Last active June 17, 2023 14:17
Show Gist options
  • Select an option

  • Save laradevitt/8a9f07860f5bd3e088c6 to your computer and use it in GitHub Desktop.

Select an option

Save laradevitt/8a9f07860f5bd3e088c6 to your computer and use it in GitHub Desktop.

Revisions

  1. laradevitt revised this gist May 14, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions d8module.install
    Original file line number Diff line number Diff line change
    @@ -29,7 +29,7 @@ function d8module_install() {
    \Drupal\Core\Database\Database::setActiveConnection('otherdb');
    $connection = \Drupal\Core\Database\Database::getConnection();

    $schema = d8module_schema_shared();
    $schema = d8module_schema_otherdb();
    foreach ($schema as $name => $table) {
    $connection->schema()->createTable($name, $table);
    }
    @@ -44,7 +44,7 @@ function d8module_uninstall() {
    \Drupal\Core\Database\Database::setActiveConnection('otherdb');
    $connection = \Drupal\Core\Database\Database::getConnection();

    $schema = d8module_schema_shared();
    $schema = d8module_schema_otherdb();
    foreach ($schema as $name => $table) {
    $connection->schema()->dropTable($name);
    }
  2. laradevitt created this gist Sep 7, 2015.
    53 changes: 53 additions & 0 deletions d8module.install
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,53 @@
    <?php

    /**
    * @file
    * Install, update and uninstall functions for the d8module module.
    */

    function d8module_schema_otherdb() {
    $schema['mytable'] = array(
    'description' => 'My table description',
    'fields' => array(
    'myfield' => array(
    'description' => 'My field description',
    'type' => 'serial',
    'size' => 'medium',
    'not null' => TRUE,
    'unsigned' => TRUE,
    ),
    ),
    'primary key' => array('myfield'),
    );
    return $schema;
    }

    /**
    * Implements hook_install().
    */
    function d8module_install() {
    \Drupal\Core\Database\Database::setActiveConnection('otherdb');
    $connection = \Drupal\Core\Database\Database::getConnection();

    $schema = d8module_schema_shared();
    foreach ($schema as $name => $table) {
    $connection->schema()->createTable($name, $table);
    }

    \Drupal\Core\Database\Database::setActiveConnection();
    }

    /**
    * Implements hook_uninstall().
    */
    function d8module_uninstall() {
    \Drupal\Core\Database\Database::setActiveConnection('otherdb');
    $connection = \Drupal\Core\Database\Database::getConnection();

    $schema = d8module_schema_shared();
    foreach ($schema as $name => $table) {
    $connection->schema()->dropTable($name);
    }

    \Drupal\Core\Database\Database::setActiveConnection();
    }