AnatolyUss / nmig

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

How to remove MySQL defaults that aren't valid PostgreSQL? #132

Open marshallm94 opened 2 months ago

marshallm94 commented 2 months ago

Is there a way to remove defaults for columns, similar to pgloader's CAST argument?

For example, I have a load file (pgloader's input) that looks like this:

LOAD DATABASE
  FROM mysql://root:XXXXXXXXXXXXXXX@localhost:3306/Stocks
  INTO postgresql://root:XXXXXXXXXXXXXXX@localhost:5432/Stocks

CAST
  type datetime when default 'utc_timestamp()' to "timestamptz default timezone('utc', now())" drop default,
  type float to numeric,
  type bigint when (= precision 20) to bigint drop typemod
;

The second line in the CAST clause could be configured in the data_types_map.json, but is there a way to configure the first line?

Thanks

AnatolyUss commented 2 months ago

Hello Marshall, Currently, there's no way to configure constraints/default removal.

On Thu, Sep 5, 2024, 2:05 PM Marshall McQuillen @.***> wrote:

Is there a way to remove defaults for columns, similar to pgloader's CAST argument https://pgloader.readthedocs.io/en/latest/ref/mysql.html#mysql-database-casting-rules ?

For example, I have a load file (pgloader's input) that looks like this:

LOAD DATABASE FROM @.:3306/Stocks INTO @.:5432/Stocks

CAST type datetime when default 'utc_timestamp()' to "timestamptz default timezone('utc', now())" drop default, type float to numeric, type bigint when (= precision 20) to bigint drop typemod ;

The second line in the CAST clause could be configured in the data_types_map.json, but is there a way to configure the first line?

Thanks

— Reply to this email directly, view it on GitHub https://github.com/AnatolyUss/nmig/issues/132, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADHR7N7CJE2SSYTBIXQI6IDZVA3GHAVCNFSM6AAAAABNWHPOXWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGUYDONBXGEYTCMI . You are receiving this because you are subscribed to this thread.Message ID: @.***>