Commit b5f0af34 authored by catch's avatar catch

Issue #1919910 by larowlan: Refactor custom_block() upgrade path to create...

Issue #1919910 by larowlan: Refactor custom_block() upgrade path to create tables using hook_schema_0() instead of in block_update_N().
parent a076b28f
......@@ -201,104 +201,6 @@ function block_update_8006() {
* only enabled during upgrade process.
*/
function block_update_8007() {
// Add the {custom_block} table.
db_create_table('custom_block', array(
'description' => 'Stores contents of custom-made blocks.',
'fields' => array(
'id' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => "The block's {custom_block}.id.",
),
'uuid' => array(
'description' => 'Unique Key: Universally unique identifier for this entity.',
'type' => 'varchar',
'length' => 128,
'not null' => FALSE,
),
'info' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => 'Block description.',
),
// Defaults to NULL in order to avoid a brief period of potential
// deadlocks on the index.
'revision_id' => array(
'description' => 'The current {block_custom_revision}.revision_id version identifier.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'default' => NULL,
),
'type' => array(
'description' => 'The type of this custom block.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'langcode' => array(
'description' => 'The {language}.langcode of this node.',
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array('id'),
'indexes' => array(
'block_custom_type' => array(array('type', 4)),
),
'unique keys' => array(
'revision_id' => array('revision_id'),
'uuid' => array('uuid'),
'info' => array('info'),
),
'foreign keys' => array(
'custom_block_revision' => array(
'table' => 'custom_block_revision',
'columns' => array('revision_id' => 'revision_id'),
),
),
));
// Add the {custom_block_revision} table.
db_create_table('custom_block_revision', array(
'description' => 'Stores contents of custom-made blocks.',
'fields' => array(
'id' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => "The block's {custom_block}.id.",
),
// Defaults to NULL in order to avoid a brief period of potential
// deadlocks on the index.
'revision_id' => array(
'description' => 'The current version identifier.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'log' => array(
'description' => 'The log entry explaining the changes in this version.',
'type' => 'text',
'not null' => TRUE,
'size' => 'big',
),
'info' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => 'Block description.',
),
),
'primary key' => array('revision_id'),
));
// Populate the {custom_block} and {custom_block_revision} table.
$results = db_select('block_custom', 'bc')->fields('bc')->execute();
......
......@@ -109,3 +109,108 @@ function custom_block_schema() {
);
return $schema;
}
/**
* Implements hook_schema_0().
*/
function custom_block_schema_0() {
$schema = array();
$schema['custom_block'] = array(
'description' => 'Stores contents of custom-made blocks.',
'fields' => array(
'id' => array(
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => "The block's {custom_block}.id.",
),
'uuid' => array(
'description' => 'Unique Key: Universally unique identifier for this entity.',
'type' => 'varchar',
'length' => 128,
'not null' => FALSE,
),
'info' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => 'Block description.',
),
// Defaults to NULL in order to avoid a brief period of potential
// deadlocks on the index.
'revision_id' => array(
'description' => 'The current {block_custom_revision}.revision_id version identifier.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => FALSE,
'default' => NULL,
),
'type' => array(
'description' => 'The type of this custom block.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'langcode' => array(
'description' => 'The {language}.langcode of this node.',
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array('id'),
'indexes' => array(
'block_custom_type' => array(array('type', 4)),
),
'unique keys' => array(
'revision_id' => array('revision_id'),
'uuid' => array('uuid'),
'info' => array('info'),
),
'foreign keys' => array(
'custom_block_revision' => array(
'table' => 'custom_block_revision',
'columns' => array('revision_id' => 'revision_id'),
),
),
);
$schema['custom_block_revision'] = array(
'description' => 'Stores contents of custom-made blocks.',
'fields' => array(
'id' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => "The block's {custom_block}.id.",
),
// Defaults to NULL in order to avoid a brief period of potential
// deadlocks on the index.
'revision_id' => array(
'description' => 'The current version identifier.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'log' => array(
'description' => 'The log entry explaining the changes in this version.',
'type' => 'text',
'not null' => TRUE,
'size' => 'big',
),
'info' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => 'Block description.',
),
),
'primary key' => array('revision_id'),
);
return $schema;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment