I need to change a field from INT to BIGINT or DECIMAL. I tested changing it directly in the database on field_data
and field_revision
tables and apparently all is working fine, but I have my doubts and I don't want to do that on production until I'm entirely sure it's safe. It's enough to change the data type on database or I have to do something else like the solutions listed in the links below? If it's not safe to just change it in database, I'd like to know why.
-
1It really depends on how you are using it. If you don't mind to possibly lose precision, you are good to go.– MołotFeb 5, 2016 at 21:31
2 Answers
Usually, when you make a change of this type it is recommended to make it in a development environment, so you can make some test to check your site is working correctly.
In the case you decide to make it in a production environment, be sure you make a backup of your database, in order to restore your system in case of problems.
-
Thanks for your answer, but that's not what I'm asking. I currently do that on a testing environment, probably my redaction was not good (english is not my native language). I'm not asking for best practices when doing changes, I'm asking if it's enough to do that change directly on database or I must do it differently to avoid any issues later.– CamiloFeb 5, 2016 at 21:03
-
@Camilo I think that in this case you can find the answer in the 3 references that you have in the question Feb 5, 2016 at 21:06
-
That's my suspicion, but what I do work fine (for now). If my solution is not safe, I'd like a reason why it is not safe. (I edited my question)– CamiloFeb 5, 2016 at 21:13
If you want to be safe, here is what I would do.
If you can view your Drupal database with phpmyadmin or some other package/program/tool.
Export the field in question DB table that you want to change as a CSV file.
Add your new field, then edit 1 node and add a value to that field. Export the new field (which has 1 value) as a CSV file.
Open both CSV files in excel. Copy the node id (nid) column and the field value column from the field in question CSV to the New CSV and save changes.
Import New CSV to the New Field DB Table.
Do the above again for the _revision
version of the table.
Flush the Drupal Cache.
Delete the field in question.