mysql-to-strict

command module
v0.0.0-...-922fd33 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 28, 2023 License: MIT Imports: 13 Imported by: 0

README

Convert MySQL Database to Strict

This tool can be used to convert an existing MySQL database to a database which will run on a MySQL server which is running in strict mode.

Disclaimer

Before running the generated queries, always backup your database! I'm not a Database Administrator (DBA), this tool is working for my specific needs. Besides that this is my first Golang project. I wrote this tool, because I needed to migrate multiple databases to run on a MySQL Strict server.

License

Please check out the LICENSE file, included in the source code.

Checks

  • Table engines are InnoDB.
  • MySQL Datetimes are not '0000-00-00 00:00:00'.
  • MySQL Dates are not '0000-00-00'.
  • Enum don't contain empty values.

Usage

# For help
$ mysql-to-strict --help

# Use tty for password.
$ mysql-to-strict --host=localhost --user=root --name=databasename

# Use password from shell (not recommended)
$ mysql-to-strict --host=localhost --user=root --password=pa$$w0rd --name=databasename

# It's also possible to use short flags.
$ mysql-to-strict -h localhost -u root -n databasename

# Forcing output of update queries.
$ mysql-to-strict --host=localhost --user=root --password=pa$$w0rd --name=databasename --force

Usage with Docker

If you do not want to compile the program yourself, you can use my prepaired Docker container.

docker run -it tomkeur/mysql-to-strict mysql-to-strict --host=localhost --user=root --name=databasename
Flags
Short Long Envvar Description
-h --host=HOST MYSQL_HOST Connect to host. ip:port or hostname:port.
-u --user=USER MYSQL_USERNAME User for login.
-p --password=PASSWORD MYSQL_PASSWORD Password to use when connecting to server. If password is not given it's asked from the tty.
-n --name=NAME MYSQL_DATABASE Database name.
-f --filename=NAME FILENAME Generated queries will be saved to this file.
--force Force running update queries, if your table structure is correct but your data is wrong.

As you can see above: It's possible to use ENVIRONMENT variables, and even mix them up with CLI for example:

# Set environment variables
$ export MYSQL_HOST=mysql
$ export MYSQL_USERNAME=root
$ export MYSQL_PASSWORD=pa$$w0rd
# Run tool
$ mysql-to-strict -n databasename
Contributing

Thanks for your interest in the project, and your willing to contribute:

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
checks

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL