What is the correct way to change the type of a field from enum to dynamicenum?

I try to change the type of a custom field from enum to dynamicenum, for this purpose I do the following

At public/legacy/custom/Extension/modules/custom_module/Ext/Vardefs/custom_fields.php

$dictionary['custom_module']['fields']['space_name_c']['type'] = 'dynamicenum';
$dictionary['custom_module']['fields']['space_name_c']['options'] = 'cstm_space_name';
$dictionary['custom_module']['fields']['space_name_c']['massupdate'] = true;

When repairing and building I get this query to apply

/* Table : custom_module */
/*COLUMNS*/
/*MISMATCH WITH DATABASE - space_name_c -  ROW [name] => 'space_name_c'  [type] => 'varchar'  [len] => '255'  */
/* VARDEF - space_name_c -  ROW[name] => 'space_name_c'  [rname] => 'Espacio'  [vname] => 'LBL_ESPACIO_NAME'  [type] => 'dynamicenum'  [len] => '255'  [required] => ''  [importable] => 'true'  [options] => 'cstm_space_name'  [massupdate] => '1'  [dbType] => 'dynamicenum'  */
/* INDEXES */
ALTER TABLE custom_module   modify COLUMN `space_name_c` dynamicenum  NULL ;

When I execute it I get this error

Mon Feb 19 11:24:50 2024 [89911][c63f4713-1c6d-01fa-9b90-5aebd487cf5d][FATAL] Mysqli_query failed.
Mon Feb 19 11:24:50 2024 [89911][c63f4713-1c6d-01fa-9b90-5aebd487cf5d][FATAL] Executing repair query:  Query Failed: ALTER TABLE custom_module modify COLUMN `space_name_c` dynamicenum  NULL: MySQL error 1064: 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 'dynamicenum  NULL' at line 1

Any idea how to solve it? Thanks in advance

Try with

type = enum
dynamic = true

(I don’t know, but I saw something similar searching the code)

Thank you. Also, I just noticed doing a search that I did add

$dictionary['custom_module']['fields']['space_name_c']['dbtype'] = 'enum';
$dictionary['custom_module']['fields']['space_name_c']['parentenum'] = 'state';

The run script message disappears.

I understand this type change should not cause a type change in the database