Migrating from Gmail inbox: historically accurate dates

I’m in the process of migrating a large Gmail Inbox to Zammad, aprox 60000 mails.
I have set up Google App and everything is transfering right now.
The problem is that the ticket creating date gets set to fetching date, not the actual one.
I’ve noticed, that if click an article and select show raw email, i can see the correct date. So, this information is stored somewhere in the system.
I wonder if it’s possible to somehow fix the date on my emails after import, or change something in the code and re-import them correctly. I’ve been browsing Postgres database intending to try some clever SQL statement, but couldn’t find where the raw email date is stored. The code of Zammad is quite complex for me to approach, since i’ve never done anything in Ruby.

Solution: use IMAP for initial import.
If Zammad doesn’t suggest ‘archive’ option upon adding IMAP account,
replace line

   archive_possible:   archive_possible,


   archive_possible:   true,

in /app/models/channel/driver/imap.rb