You are here

function eck_update_7005 in Entity Construction Kit (ECK) 7.2

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

Update 7005.

File

./eck.install, line 294
ECK's requirements, schemas, and logic for install and uninstall.

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',
  ));
}