0.0.12 • Published 4 years ago

mysql-schema-compare v0.0.12

Weekly downloads
11
License
MIT
Repository
github
Last release
4 years ago

WIP

Description

Tool compares schemas defined in .sql files (CREATE TABLE statements) to live mysql server database.

USE ..., CREATE DATABASE..., DROP ... statements, single line and multiline comments are allowed in definitions and ignored.

Supported syntax/features

Mysql 5.x only atm.

  • Tables
    • Columns with all data types
    • Indexes
    • Foreign keys
  • Triggers
    • Whole body text compared
    • Body should be always enclosed in BEGIN ... END even if it is a single statement
    • Requires delimiter to be $$ (hardcoded in parser).
  • Stored procedures
    • Whole body text compared
    • Requires delimiter to be $$ (hardcoded in parser).
  • Views
    • Whole body text compared

Expected triggers and stored procedures bodies could contain comments. If they aren't present in target database they will be reported as differences. Make sure you import these objects to the db with --comments specified to preserve comments in target db. Like

mysql --host=localhost --port=3306 --user=root --password=root --database=db --comments < db-triggers.sql

CLI

$ mysql-schema-compare <options> <.sql files>

Database Options

ParameterDescription
--db-host stringDatabase server host name
--db-port stringDatabase server port (default 3306)
--db-user stringUser name for database connection (default root)
--db-pass stringPassword for database connection (default root)
--db-name stringSchema name of database server
--schema stringYou can specify list of sql files explicitly with this parameter

Processing options

ParameterDescription
--err-extra true/falseTreat items not described in definitions but present in database as error (default false)

Mics options

ParameterDescription
--helpDisplays this CLI usage help

Same options are also configurable with environment variables or .env file

Env variable nameDescriptionDefault value
DB_HOSTCorresponds to --db-host option
DB_PORTCorresponds to --db-port option
DB_USERCorresponds to --db-user option
DB_PASSCorresponds to --db-pass option
DB_NAMECorresponds to --db-name option
SCHEMAComma separate list of .sql files
ERR_EXTRACorresponds to --err-extra option
FULL_DIFFSInclude full body text in difference view when truefalse
IGNORE_COMMENTSIgnores one line comment changes then truetrue

Error codes

CodeMeaning
0Everything is fine, schemas match
1Schemas differ
5Definitions parsing error (could happen when parsing database actual schema if unsupported element encountered)
8Invalid configuration. Most probabl some required parameter is missing
10Exception. Please report this as issue
0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago