mirror of
https://github.com/farmOS/farmOS.git
synced 2024-02-23 11:37:38 +01:00
Do not allow null timestamp values in sensor data table.
This commit is contained in:
parent
98bc508e3d
commit
b8489b3ac0
|
@ -22,6 +22,8 @@ function farm_sensor_listener_schema() {
|
||||||
'timestamp' => array(
|
'timestamp' => array(
|
||||||
'description' => 'Timestamp of the sensor reading',
|
'description' => 'Timestamp of the sensor reading',
|
||||||
'type' => 'int',
|
'type' => 'int',
|
||||||
|
'not null' => TRUE,
|
||||||
|
'default' => 0,
|
||||||
),
|
),
|
||||||
'name' => array(
|
'name' => array(
|
||||||
'description' => 'Sensor reading name',
|
'description' => 'Sensor reading name',
|
||||||
|
@ -52,3 +54,29 @@ function farm_sensor_listener_schema() {
|
||||||
);
|
);
|
||||||
return $schema;
|
return $schema;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do not allow null timestamp values in sensor data table.
|
||||||
|
*/
|
||||||
|
function farm_sensor_listener_update_7000(&$sandbox) {
|
||||||
|
|
||||||
|
// Drop the index.
|
||||||
|
db_drop_index('farm_sensor_data', 'timestamp');
|
||||||
|
|
||||||
|
// Set all NULL values to 0.
|
||||||
|
db_query('UPDATE {farm_sensor_data} SET timestamp = 0 WHERE timestamp IS NULL');
|
||||||
|
|
||||||
|
// Change the field.
|
||||||
|
$timestamp = array(
|
||||||
|
'description' => 'Timestamp of the sensor reading',
|
||||||
|
'type' => 'int',
|
||||||
|
'not null' => TRUE,
|
||||||
|
'default' => 0,
|
||||||
|
);
|
||||||
|
$timestamp_keys = array(
|
||||||
|
'indexes' => array(
|
||||||
|
'timestamp' => array('timestamp'),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
db_change_field('farm_sensor_data', 'timestamp', 'timestamp', $timestamp, $timestamp_keys);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue