You are here

function paragraphs_update_7103 in Paragraphs 7

Update {paragraphs_bundle} schema to include label and description fields.

File

./paragraphs.install, line 188
Install, update and uninstall functions for the paragraphs module.

Code

function paragraphs_update_7103() {
  $fields = array(
    'label' => array(
      'description' => 'A user-facing label for this bundle.',
      'type' => 'varchar',
      'length' => 255,
      'not null' => TRUE,
      'default' => '',
    ),
    'description' => array(
      'description' => 'A brief description of this bundle.',
      'type' => 'text',
      'not null' => FALSE,
      'size' => 'medium',
      'default' => NULL,
    ),
  );
  foreach ($fields as $key => $field) {
    if (!db_field_exists('paragraphs_bundle', $key)) {
      db_add_field('paragraphs_bundle', $key, $field);
    }
  }

  // Set initial label value equal to name.
  db_update('paragraphs_bundle')
    ->expression('label', 'name')
    ->execute();
}