function brilliant_gallery_update_7204 in Brilliant Gallery 7
Adjust type of the datetime column to int type.
File
- ./
brilliant_gallery.install, line 88 - Install, update and uninstall functions for the brilliant_gallery module.
Code
function brilliant_gallery_update_7204() {
// Precaution (the table might have been made before without deletion).
if (db_table_exists('brilliant_gallery_image_arrays_old')) {
db_drop_table('brilliant_gallery_image_arrays_old');
}
db_query('ALTER TABLE {brilliant_gallery_image_arrays} RENAME {brilliant_gallery_image_arrays_old};');
$schema = array();
$schema['brilliant_gallery_image_arrays'] = array(
'description' => t('Binds image property array with its hash that is present in the cached file name and in the URL.'),
'fields' => array(
'hash' => array(
'description' => t('Hash of the serialized array.'),
'type' => 'varchar',
'length' => '32',
'not null' => TRUE,
),
'array' => array(
'description' => t('Array of image parametres.'),
'type' => 'text',
'not null' => TRUE,
),
'datetime' => array(
'description' => t('Date and time of last value refresh.'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
),
'primary key' => array(
'hash',
),
'indexes' => array(
'datetime' => array(
'datetime',
),
),
);
if (!db_table_exists('brilliant_gallery_image_arrays')) {
db_create_table('brilliant_gallery_image_arrays', $schema['brilliant_gallery_image_arrays']);
}
$result = db_select('brilliant_gallery_image_arrays_old', 'b')
->fields('b', array(
'hash',
'array',
'datetime',
))
->execute();
foreach ($result as $row) {
$nid = db_insert('brilliant_gallery_image_arrays')
->fields(array(
'hash' => $row->hash,
'array' => $row->array,
'datetime' => strtotime($row->datetime),
))
->execute();
}
db_drop_table('brilliant_gallery_image_arrays_old');
}