mailtrain icon indicating copy to clipboard operation
mailtrain copied to clipboard

knex migrations fail in docker

Open blwtxc opened this issue 3 years ago • 2 comments

Hi there,

found mailtrain yesterday on my quest for a new maillist system and wanted to have a look and try it out ... easy! ... well, so I thought ...

My setup: OS: Ubuntu 20.04 node: v18.6.0 Docker: 20.10.17

... so ... installing from source didn't work (I guess because that's all a bit too new ... and the setup scripts are a bit too brute-force for my taste. Don't get me wrong, they might be fine if I want to install mailtrain on a dedicated machine, but that is not my case ...) But hold on! There's a dockerized version. So ... dig, dig, dig through the compose file ... it wants MariaDB, Redis and Mongo, all fine with me. But I already have running instances of MySQL and Redis, why not use them, so the only thing I need is a Mongo instance. After fiddling around with the environment variables I think I found something that should work, so I thought... Besause all that try and error took a severe amount of time I decided to ask you guys for help.

Here's my docker command to run the mailtrain container:

docker run \
--name mailtrain \
--network my_net \
--ip 172.28.5.201 \
--hostname mailtrain \
--restart always \
--volume /opt/mailtrain/data:/app/server/files \
--publish 127.0.0.1:23000:3000 \
--publish 127.0.0.1:23003:3003 \
--publish 127.0.0.1:23004:3004 \
--env ADMIN_PASSWORD=<very secret> \
--env WWW_HOST=127.0.0.1 \
--env WWW_PROXY=true \
--env MONGO_HOST=172.28.5.200 \
--env REDIS_HOST=172.28.5.2 \
--env REDIS_PORT=6379 \
--env MYSQL_HOST=172.28.5.4 \
--env MYSQL_PORT=3306 \
--env MYSQL_DATABASE=mailtrain \
--env MYSQL_USER=mailtrain \
--env MYSQL_PASSWORD=<very very secret> \
--env DEFAULT_LANGUAGE='de-DE' \
--detach \
mailtrain/mailtrain:latest

(In case you didn't notice ... I do like my switches verbose ;) )

I see that it is able to dump the SQL into my database, so I assume it is able to connect to my MySQL instance. Because I read -- in another issue -- that Redis and Mongo are used for ZoneMTA only, a service I didn't activate yet, I don't concern myself with these connections for now.

So what's the problem you might ask. It doesn't work (... I hope that error description is enough for you to tell me what's wrong. What? No!?!)

When inspecting the logs it seems that knex is unable to run its migrations.

Here's a part of the log

ERR!   code: 'ER_NO_SUCH_TABLE',
ERR!   errno: 1146,
ERR!   sqlMessage: 'Table \'mailtrain.undefined\' doesn\'t exist',
ERR!   sqlState: '42S02',
ERR!   index: 0,
ERR!   sql:
ERR!    'ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;ALTER TABLE undefined CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;' }

Digging through the source a bit I assume that something goes wrong when knex tries to template some SQL requests.

Perhaps that's sufficient info for you wizzards to lend me a helping hand. :)

So long, belowtoxic

blwtxc avatar Jul 22 '22 10:07 blwtxc

Someone? Anyone? Bueller? Bueller?...

blwtxc avatar Jul 26 '22 06:07 blwtxc

The following is fixing it for me. For you too?

sed -i \
    -e "s|].table_name|].TABLE_NAME|" \
    server/setup/knex/migrations/20200824160149_convert_to_utf8mb4.js

jfqd avatar Oct 12 '22 10:10 jfqd

We are going to start with the development and testing of mailtrain v3 in the next weeks.

You are welcome to help us with the testing as soon as the first release candidate is available.

forgeOneHQ avatar Mar 16 '24 09:03 forgeOneHQ