A radical tool for converting MySQL database dumps for use with CockroachDB
Install as you would a normal package:
go get -u github.com/LUSHDigital/radroach
Firstly you must have a pre-prepared MySQL dump ready for conversion. Radroach
requires you to have created this using mysqldump
with some specific options:
mysqldump -h[host] -u[user] -p[database name] --compatible=postgresql --compact --skip-add-drop-table --skip-add-locks --skip-comments > dump.sql
Opinionated I know but it makes our lives much easier
To generate a MySQL dump for a MySQL table hosted in Docker, use the following steps:
- Jump into the MySQL Docker container shell:
docker exec -it <CONTAINER> /bin/bash
-
Run
mysqldump
as outlined above. -
Copy the file/contents of dump.sql and use that as the input to
radroach
.
Then you just need to run radroach
passing it your source file and the name of
the destination file:
radroach [FLAGS...] SOURCE_MYSQL_DUMP DESTINATION_CRDB_DUMP
Usage: radroach [FLAGS...] SOURCE_MYSQL_DUMP DESTINATION_CRDB_DUMP
-enum-to-check
convert enums to check constraints
-verbose
verbose logging mode
- Load MySQL dump
- Simple regex replacements for types and syntax
- Break dump down by table, extract foreign keys
- Re-write dump with foreign keys after table creation
- Produce a working SQL dump for CockroachDB
- Refactor codebase for readability and testability
- Test all the things
- Cobra cmd support