2017 © Pedro Peláez
 

library mysql-workbench-schema-exporter

image

fi/mysql-workbench-schema-exporter

  • Monday, July 30, 2018
  • by manzolo
  • Repository
  • 2 Watchers
  • 0 Stars
  • 703 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 128 Forks
  • 0 Open issues
  • 14 Versions
  • 0 % Grown

The README.md

README

What is MySQL Workbench Schema Exporter?

MySQL Workbench Schema Exporter is a library to transform the MySQL Workbench model (*.mwb) to useful another schemas., (*1)

It is inspired by mysql-workbench-doctrine-plugin., (*2)

Currently, MySQL Workbench Schema Exporter can export the model to various schemas using a formatter plugin:, (*3)

The actual conversion to another schema is done using an exporter. These plugins are available in subprojects: * Doctrine1 Exporter * Doctrine2 Exporter * Propel1 Exporter * Zend Framework 1 Exporter * Node Exporter, (*4)

Prerequisites

  • PHP 5.4+
  • Composer to install the dependencies

Installation

Using Composer

  1. In your project directory issue:, (*5)

    php composer.phar require --dev mysql-workbench-schema-exporter/mysql-workbench-schema-exporter, (*6)

  2. You then can invoke the CLI script using vendor/bin/mysql-workbench-schema-export., (*7)

  3. You can directly require an exporter for your project:, (*8)

    php composer.phar require --dev mysql-workbench-schema-exporter/doctrine2-exporter, (*9)

Stand alone

  1. Get the source code using Git or download from Github.
  2. Get composer.
  3. Install dependencies:, (*10)

    php composer.phar install, (*11)

  4. You then can invoke the CLI script using bin/mysql-workbench-schema-export., (*12)

Configuring MySQL Workbench Schema Exporter

MySQL Workbench Schema Exporter can be configured at runtime using methods:, (*13)

  • Setup options.
  • Model comment, either applied to table, column, or foreign key object.

Both methods accept different options, and generally divided as common options and exporter (formatter) specific options., (*14)

Common Setup Options

General options applied to all formatter., (*15)

  • filename, (*16)

    The output filename format, use the following tag %schema%, %table%, %entity%, and %extension% to allow the filename to be replaced with contextual data., (*17)

    Default is %entity%.%extension%., (*18)

  • indentation, (*19)

    The indentation size for generated code., (*20)

  • useTabs, (*21)

    Use tabs for indentation instead of spaces. Setting this option will ignore the indentation-option., (*22)

  • eolDelimeter, (*23)

    EOL type for generated code. Supported EOLs are win and unix., (*24)

  • addGeneratorInfoAsComment, (*25)

    Add generator information to the generated code as a comment., (*26)

    Default is true., (*27)

  • skipPluralNameChecking, (*28)

    Skip checking the plural name of model and leave as is, useful for non English table names., (*29)

    Default is false., (*30)

  • backupExistingFile, (*31)

    If target already exists create a backup before replacing the content., (*32)

    Default is true., (*33)

  • enhanceManyToManyDetection, (*34)

    If enabled, many to many relations between tables will be added to generated code., (*35)

    Default is true., (*36)

  • sortTablesAndViews, (*37)

    If enabled, sorting of tables and views is performed prior to code generation for each table and view. For table, it sorted by table model name and for view sorted by view model name., (*38)

    Default is true., (*39)

  • exportOnlyTableCategorized, (*40)

    If specified, only export the tables if its category matched., (*41)

  • logToConsole, (*42)

    If enabled, output the log to console., (*43)

    Default is false., (*44)

  • logFile, (*45)

    If specified, output the log to a file. If this option presence, option logToConsole will be ignored instead., (*46)

    Default is empty., (*47)

  • stripMultipleUnderscores, (*48)

    If enabled, consider multiple underscores as single ones so for example, a table named user__group will still produce a UserGroup entity., (*49)

    Default is false., (*50)

  • asIsUserDatatypePrefix, (*51)

    This option gives the ability to bypass user type convertion and forward user type to models, as is., (*52)

    For example, if defined to _, and a user type _BOOLEAN is defined in MySQL Workbench (resolving to TINYINT(1), for example, but no matter), then the model field will have BOOLEAN., (*53)

    It is usefull for non MySQL types like BOOLEAN or JSONB that certain ORMs can handle., (*54)

    Default is "" (disabled)., (*55)

Common Model Comment Behavior

  • {MwbExporter:external}true{/MwbExporter:external} (applied to Table, View), (*56)

    Mark table/view as external to skip table/view code generation. For Doctrine use {d:external}true{/d:external} instead., (*57)

  • {MwbExporter:category}mycategory{/MwbExporter:category} (applied to Table), (*58)

    Table category used to groups the table for sorting. This way, generated table output can be sorted as you need such as in Propel YAML schema (obviously useful for exporter which results in single file output)., (*59)

Formatter Setup Options

Command Line Interface (CLI)

The mysql-workbench-schema-export command helps export a workbench schema model directly from command line. It has feature to customize export configuration before exporting. By default, it will use config file export.json located in the current directory to supply the parameter if it find it. To disable this behaviour, see the option below., (*60)

Command usage:, (*61)

php bin/mysql-workbench-schema-export [options] FILE [DEST]

Where:, (*62)

  • FILE, (*63)

    The MySQL Workbench model file to export., (*64)

  • DEST, (*65)

    The destination directory (optional), if not specified current directory assumed., (*66)

Options:, (*67)

  • --export=type, (*68)

    Choose the result of the export, supported type can be obtained using --list-exporter. If this option is omitted and no config file found, the CLI will prompt to choose which exporter to use., (*69)

  • --config=file, (*70)

    Read export parameters from file (in JSON format)., (*71)

  • --saveconfig, (*72)

    Save export parameters to file export.json, later can be used as value for --config=file., (*73)

  • --list-exporter, (*74)

    Show all available exporter., (*75)

  • --no-auto-config, (*76)

    Disable automatic config file lookup., (*77)

  • --zip, (*78)

    Compress the result., (*79)

  • --help, (*80)

    Show the usage (or suppress any parameters)., (*81)

Sample usage:, (*82)

php bin/mysql-workbench-schema-export --export=doctrine1-yaml example/data/test.mwb ./generated
php bin/mysql-workbench-schema-export --zip example/data/test.mwb

Sample export parameters (JSON) for doctrine2-annotation:, (*83)

{
    "export": "doctrine2-annotation",
    "zip": false,
    "dir": "temp",
    "params": {
        "backupExistingFile": true,
        "skipPluralNameChecking": false,
        "enhanceManyToManyDetection": true,
        "bundleNamespace": "",
        "entityNamespace": "",
        "repositoryNamespace": "",
        "useAnnotationPrefix": "ORM\\",
        "useAutomaticRepository": true,
        "indentation": 4,
        "filename": "%entity%.%extension%",
        "quoteIdentifier": false
    }
}

Using MySQL Workbench Schema Exporter as Library

If you want to use MySQL Workbench Schema Exporter as a library for other project. See the included usage in the example folder., (*84)

Test Database

The Versions

30/07 2018

v1.0.0

1.0.0.0

  Sources   Download

11/01 2017

dev-master

9999999-dev https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter

MySQL Workbench Schema Exporter

  Sources   Download

MIT

The Requires

 

by Johannes Mueller
by Toha
by Robert Vock

database cli zend doctrine mysql propel extjs mysql workbench sequelizejs

11/01 2017

v3.0.3

3.0.3.0 https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter

MySQL Workbench Schema Exporter

  Sources   Download

MIT

The Requires

 

by Johannes Mueller
by Toha
by Robert Vock

database cli zend doctrine mysql propel extjs mysql workbench sequelizejs

28/02 2016

v3.0.2

3.0.2.0 https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter

MySQL Workbench Schema Exporter

  Sources   Download

MIT

The Requires

 

by Johannes Mueller
by Toha
by Robert Vock

database cli zend doctrine mysql propel extjs mysql workbench sequelizejs

23/01 2016

v3.0.1

3.0.1.0 https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter

MySQL Workbench Schema Exporter

  Sources   Download

MIT

The Requires

 

by Johannes Mueller
by Toha
by Robert Vock

database cli zend doctrine mysql propel extjs mysql workbench sequelizejs

09/01 2016

v3.0.0

3.0.0.0 https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter

MySQL Workbench Schema Exporter

  Sources   Download

MIT

The Requires

 

by Johannes Mueller
by Toha
by Robert Vock

database cli zend doctrine mysql propel extjs mysql workbench sequelizejs

22/12 2014

v2.1.6

2.1.6.0 https://github.com/johmue/mysql-workbench-schema-exporter

MySQL Workbench Schema Exporter

  Sources   Download

MIT

The Requires

 

by Johannes Mueller
by Toha

database cli zend doctrine mysql propel extjs mysql workbench sequelizejs

13/07 2014

v2.1.5

2.1.5.0 https://github.com/johmue/mysql-workbench-schema-exporter

MySQL Workbench Schema Exporter

  Sources   Download

MIT

The Requires

 

by Johannes Mueller
by Toha

database cli zend doctrine mysql propel extjs mysql workbench sequelizejs

10/07 2014

v2.1.4

2.1.4.0 https://github.com/johmue/mysql-workbench-schema-exporter

MySQL Workbench Schema Exporter

  Sources   Download

MIT

The Requires

 

by Johannes Mueller
by Toha

database cli zend doctrine mysql propel extjs mysql workbench sequelizejs

27/05 2014

v2.1.3

2.1.3.0 https://github.com/johmue/mysql-workbench-schema-exporter

MySQL Workbench Schema Exporter

  Sources   Download

MIT

The Requires

 

by Johannes Mueller
by Toha

database cli zend doctrine mysql propel extjs mysql workbench sequelizejs

16/04 2014

v2.1.2

2.1.2.0 https://github.com/johmue/mysql-workbench-schema-exporter

MySQL Workbench Schema Exporter

  Sources   Download

MIT

The Requires

 

by Johannes Mueller
by Toha

database cli zend doctrine mysql propel extjs workbench sequelizejs

15/04 2014

v2.1.1

2.1.1.0 https://github.com/johmue/mysql-workbench-schema-exporter

MySQL Workbench Schema Exporter

  Sources   Download

MIT

The Requires

 

by Johannes Mueller
by Toha

database cli zend doctrine mysql propel extjs workbench sequelizejs

08/04 2014

v2.1.0

2.1.0.0 https://github.com/johmue/mysql-workbench-schema-exporter

MySQL Workbench Schema Exporter

  Sources   Download

MIT

The Requires

 

by Johannes Mueller
by Toha

database cli zend doctrine mysql propel extjs workbench sequelizejs

04/04 2014

v2.0.0

2.0.0.0 https://github.com/johmue/mysql-workbench-schema-exporter

MySQL Workbench Schema Exporter

  Sources   Download

MIT

The Requires

 

by Johannes Mueller
by Toha

database cli zend doctrine mysql propel extjs workbench sequelizejs