Created
November 25, 2016 12:53
-
-
Save rindevich/ce6e231e3b43b303304dfcbc35a8ab70 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Change type for existing Field. Drupal. | |
*/ | |
$field = 'field_example'; | |
db_change_field('field_data_' . $field, $field . '_value', $field . '_value', array( | |
'type' => 'numeric', | |
'precision' => 10, | |
'scale' => 2, | |
'not null' => FALSE, | |
)); | |
db_change_field('field_revision_' . $field, $field . '_value', $field . '_value', array( | |
'type' => 'numeric', | |
'precision' => 10, | |
'scale' => 2, | |
'not null' => FALSE, | |
)); | |
$s = db_query("SELECT * FROM {field_config} where field_name = :name", array(':name' => $field))->fetchObject(); | |
$data = unserialize($s->data); | |
$data['settings'] = array( | |
'precision' => '10', | |
'scale' => '2', | |
'decimal_separator' => '.', | |
); | |
$data = serialize($data); | |
db_update('field_config') | |
->fields(array( | |
'data' => serialize($data), | |
'type' => 'number_decimal', | |
)) | |
->condition('field_name', $field) | |
->execute(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment