pgloader icon indicating copy to clipboard operation
pgloader copied to clipboard

pg to pg timestamp(6)

Open ruhuansanmei opened this issue 3 years ago • 2 comments

can we define this function this way, because now version 3.6.7 cause pg to pg failed from the type timestamp without time zone(6), the right type is timestamp(6)

(defun get-column-type-name-from-sqltype (column)
  "Return the column type name. When column-type is a sqltype, the sqltype
   might be either an ENUM or a SET. In the case of a SET, we want an array
   type to be defined here."
  (let ((type-name (column-type-name column)))
    (print (string type-name))
    (if (string-equal (string type-name) "timestamp without time zone(6)")
      (progn
        (print "xxxxxx")
        "timestamp(6)"
      )
       (typecase type-name
      (sqltype (ecase (sqltype-type type-name)
                 (:enum (format nil "~@[~a~].~a"
                                (schema-name (sqltype-schema type-name))
                                (sqltype-name type-name)))
                 (:set  (format nil "~@[~a~].~a[]"
                                (schema-name (sqltype-schema type-name))
                                (sqltype-name type-name)))))
      (string  type-name))
    )
      ))

ruhuansanmei avatar Aug 16 '22 13:08 ruhuansanmei

Hi @ruhuansanmei ; can you provide with more details about what's failing? If you could prepare a small SQL file that creates a database with a single table and a couple lines that contain the problem when migrated from a Postgres database to another, that'd be great, for instance. Otherwise share at least the logs and errors messages with data samples that we can see.

dimitri avatar Aug 17 '22 14:08 dimitri

Oh and also if your source database is SQLite, then you can spell datatypes anyway you want there. Please then see about user defined casting rules: https://pgloader.readthedocs.io/en/latest/ref/sqlite.html#sqlite-database-casting-rules

dimitri avatar Aug 17 '22 14:08 dimitri