hi to all,
I want to change a column datatype from varchar to int. I wrote this call to db_change_column:
db_change_column($ret, "impegni_pratiche","istituto", "istituto", "int", array('unsigned'=>true,'not null' => true));
But, when I run update.php, it return me this error:
# user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TO istituto_old' at line 1 query: ALTER TABLE impegni_pratiche RENAME istituto TO istituto_old in /var/www/drupal/update.php on line 125.
# user warning: Duplicate column name 'istituto' query: ALTER TABLE impegni_pratiche ADD istituto int in /var/www/drupal/update.php on line 126.
# user warning: Unknown column 'istituto_old' in 'field list' query: UPDATE impegni_pratiche SET istituto = istituto_old in /var/www/drupal/update.php on line 127.
# user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOT NULL' at line 1 query: ALTER TABLE impegni_pratiche ALTER istituto SET NOT NULL in /var/www/drupal/update.php on line 129.
# user warning: Can't DROP 'istituto_old'; check that column/key exists query: ALTER TABLE impegni_pratiche DROP istituto_old in /var/www/drupal/update.php on line 130.
Comments
From the documentation for
From the documentation for db_change_column:
You wan to use db_change_field().
Contact me to contract me for D7 -> D10/11 migrations.