AnatolyUss / nmig

NMIG is a database migration tool, written in Node.js and highly inspired by FromMySqlToPostgreSql.
GNU General Public License v3.0
451 stars 83 forks source link

boolean to int #90

Closed Marzie79 closed 2 years ago

Marzie79 commented 2 years ago

hello guys. I think nmig is perfect but I have an issue with it. boolean type in mysql convert to int type in postgresql and I don't know why this thing happens

AnatolyFromPerion commented 2 years ago

Hello Marzie, As long as I know, in MySQL boolean is an alias of tinyint(1). The show full columns from {some_table}; queries emit only tinyint(1) for boolean columns, hence nmig creates smallint columns in such cases.

Solution proposal: Have a look at /nmig/config/data_types_map.json file. This is a configuration, defining how to map MySQL data types to PostgreSQL. Find the tinyint definition. (line 33) If you certain that all the tinyint columns in your database are actually booleans, then change type value to boolean instead of smallint. Then rerun nmig.

If you discovered this issue after converting your production database, then try to convert these columns to boolean. Something like this: alter table table_name alter column column_name type bool using column_name::int::bool;

Marzie79 commented 2 years ago

yes. Your answer is correct. My problem was solved. Thank you so much for your answer.

AnatolyFromPerion commented 2 years ago

My pleasure, Marzie. Thanks for the feedback!