dimitri / pgloader

Migrate to PostgreSQL in a single command!

Home Page:http://pgloader.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature: Configuration File for Type Conversion overrides?

kirkw opened this issue · comments

I used this for a SQLite DB. Unfortunately everything "*char" -> "text".
Which in my world is "memo" (not varchar).

I am certain I am not the only one who would love some kind of configuration file that lets me specify the types.
A section in an INI file (current value = new value) format:
[type_conversions]
varchar(40) = character varying(40)
varchar(50) = character varying(50)
varchar(60) = character varying(60)
varchar(70) = character varying(70)
varchar = TEXT
nvarchar(40) = character varying(40)
nvarchar(50) = character varying(50)
nvarchar(60) = character varying(60)
nvarchar(70) = character varying(70)
nvarchar = TEXT
TEXT = TEXT

So, you could keep your core routine, to get the "default" value.
but lookup the type conversion and use the default if you don't find one:
new_type = config.get_text('type_conversions', old_type, default = new_type)

the ONLY thing I would add is a level of debug output that would emit the rows
and the types
if (debug_verbose) print('{old_type} = {new_type}')

Which would make creating such a file trivial...

Thanks!