Skip to content

Combodo/mysql-faked-dump

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mysql faked dump ALPHA

Create censored dump with a finger snap!

🚫 This tool is an alpha version and should not be used.

prerequisites

In order to install the dependencies, you need composer, and as this tool relies on symfony 4, you'll need at least php 7.1.

installation

composer install

usage

Just call bin/console mysql-faked:dump with one parameter: the path to a valid config file. It will output the dump on the stdout. The dump progress is output on the stderr.

you can store the dump by redirecting stdout to a file:

bin/console mysql-faked:dump path/to/file.yaml > ~/Desktop/dump.sql

or directly execute it :

bin/console mysql-faked:dump path/to/file.yaml | mysql --host=remote_host -C db_name

this command accept two options :

  • skip-drop-table
  • skip-create-table

configuration

The configuration is written in yaml, it has three main entries.

example:
data_source:
  dsn: 'mysql:dbname=foo;host=localhost;port=3600'
  user: 'root'
  password: ~
  options: []
options:
  exclude_missing_tables: false
tables:
  fos_user:
    preserve_filter:
      preserve: "email like '%@combodo.com' or id=1"
      reverse: "(email not like '%@combodo.com' or email is null) and id!=1"
    columns:
      email:
        faker: unique.email
        alias: [email_canonical]
      last_name:
        faker: lastName
      company:
        faker: company
      password:
        empty: true
  oauth_*:
    pattern: "oauth_.*"
    exclude: true
data_source:

This part describes how to connect to mysql. see PDO::__construct in order to see how to configure it more deeply

options:

for now only one option exists:

  • exclude_missing_tables: whether non mapped table should be dumped or ignored.
tables

This entry lets you configure special cases:

  • ignore tables: exclude: true
  • special values for columns
    • empty value: empty: true
    • fake value : faker: company
  • preserve some rows from being faked preserve_filter
    • in this case, you need to provide both the preserve and the reverse filter. They will be applied as SQL WHERE clauses.

NB : fake values are generated by using the Faker library, so you can use every formatter provided, or even write your own. Behind the scene, Symfony's property accessor is used, so you can easily create complex calls (ie for calling $faker->unique->email() just type unique.email in order to obtain guaranteed unique email)

pattern

If you want to map many tables within one configuration entry, use an impossible to match table name (ie: oauth_*) and configure a pattern (ie pattern: "oauth_.*").

alias

Faker will give you a different result on each call, so if you want many columns to share the same value, configure an alias (ie: alias: [table2, table3]).

About

No description or website provided.

Topics

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •