Crear un esquema Drupal 7

.install

<?php

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

/**
 * Implements hook_install().
 */
function indicadores_economicos_install()
{
    $fuente = new stdClass();
    $fuente->title = 'Manual';
    $fuente->data = serialize(array('type'=>'Manual'));
    $fuente->uid = 1;
    $fuente->status = 1;
    $fuente->created = REQUEST_TIME;
    drupal_write_record('indicadores_fuentes', $fuente);
}

/**
 * Implements hook_uninstall().
 */
function indicadores_economicos_uninstall()
{
}


/**
 * Implements hook_schema().
 */
function indicadores_economicos_schema()
{
    $schema['indicadores_fuentes'] = array(
        'description' => 'The base table for sources of economic indicators.',
        'fields' => array(
            'ifid' => array(
                'description' => 'The primary identifier for a source of economic indicator.',
                'type' => 'serial',
                'unsigned' => TRUE,
                'not null' => TRUE,
            ),
            'title' => array(
                'description' => 'The title of this source of economic indicator.',
                'type' => 'varchar',
                'length' => 255,
                'not null' => TRUE,
                'default' => '',
            ),
            'data' => array(
                'description' => 'The DATA of source of economic indicator.',
                'type' => 'text',
                'size' => 'normal',
                'not null' => TRUE,
                'default' => '',
            ),
            'uid' => array(
                'description' => 'The {users}.uid that owns this node; initially, this is the user that created it.',
                'type' => 'int',
                'not null' => TRUE,
                'default' => 0,
            ),
            'status' => array(
                'description' => 'Boolean indicating whether the mass media is published (visible to non-administrators).',
                'type' => 'int',
                'not null' => TRUE,
                'default' => 1,
            ),
            'created' => array(
                'description' => 'The Unix timestamp when the mass media was created.',
                'type' => 'int',
                'not null' => TRUE,
                'default' => 0,
            ),
        ),
        'indexes' => array(
          'economic_indicator_created'  => array('created'),
          'uid'                 => array('uid'),
          'status'                 => array('status'),
        ),
        'primary key' => array('ifid'),
    );
   
    $schema['indicadores_economicos'] = array(
        'description' => 'The base table for economic indicators.',
        'fields' => array(
            'ieid' => array(
                'description' => 'The economic indicator ID in the specified economic indicator.',
                'type' => 'serial',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 0,
            ),
            'ifid' => array(
                'description' => 'The source indicator ID in the specified economic indicator.',
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 0,
            ),
            'title' => array(
                'description' => 'The title of this source of economic indicator.',
                'type' => 'varchar',
                'length' => 255,
                'not null' => TRUE,
                'default' => '',
            ),
            'value' => array(
                'description' => 'The value of the specified economic indicator.',
                'type' => 'varchar',
                'length' => 50,
                'not null' => TRUE,
                'default' => '',
            ),
            'variation' => array(
                'description' => 'The variation of the specified economic indicator.',
                'type' => 'int',
                'unsigned' => FALSE,
                'not null' => TRUE,
                'default' => 0,
            ),
            'status' => array(
                'description' => 'Boolean indicating whether the economic indicator is published (visible to non-administrators).',
                'type' => 'int',
                'unsigned' => TRUE,
                'not null' => TRUE,
                'default' => 1,
            ),
            'weight' => array(
                'description' => 'The weight of this economic indicator in relation to other economic indicators.',
                'type' => 'int',
                'not null' => TRUE,
                'default' => 0,
            ),
            'modified' => array(
                'description' => 'The Unix timestamp when the economic indicator was modified.',
                'type' => 'int',
                'not null' => TRUE,
                'default' => 0,
            ),
        ),
        'indexes' => array(
          'source_economic_indicator'   => array('ieid', 'ifid'),
          'economic_indicator_tree'   => array('ieid', 'weight', 'title'),
        ),
        'primary key' => array('ieid'),
        'foreign keys' => array(
            'indicadores_fuentes' => array(
                'table' => 'indicadores_fuentes',
                'columns' => array('ifid' => 'ifid'),
            ),
        ),
    );

    return $schema;
}

Comentarios

Entradas populares