You are here

function eck_update_7005 in Entity Construction Kit (ECK) 7

Same name and namespace in other branches
  1. 7.3 eck.install \eck_update_7005()
  2. 7.2 eck.install \eck_update_7005()

File

./eck.install, line 290
This install file creates a table for the this module to store information about entities. Well, the only information that it needs to store is a name and a label for each entity created, the rest of the information is generated by the functions.

Code

function eck_update_7005() {

  //change the name of the eck table to eck_entity_type
  db_rename_table('eck', 'eck_entity_type');

  //change the name of the eck_types table to eck_bundle
  db_rename_table('eck_types', 'eck_bundle');

  //remove the id key from eck_entity_type
  db_drop_field('eck_entity_type', 'id');

  //create the index with the right field names
  db_add_primary_key('eck_entity_type', array(
    'name',
  ));

  //drop the eck_bundle index entity_type
  db_drop_index('eck_bundle', 'entity_type');

  //change eck_bundle entity field to entity_type
  db_change_field('eck_bundle', 'entity', 'entity_type', array(
    'description' => "The entity type this bundle belongs to",
    'type' => 'varchar',
    'type' => 'varchar',
    'length' => 128,
    'not null' => TRUE,
  ));

  //change eck_bundle type field to name
  db_change_field('eck_bundle', 'type', 'name', array(
    'description' => "The bundle's name",
    'type' => 'varchar',
    'type' => 'varchar',
    'length' => 128,
    'not null' => TRUE,
  ));

  //create the index with the right field names
  db_add_index('eck_bundle', 'entity_type_bundle_name', array(
    'entity_type',
    'name',
  ));
}