Create censored dump with a finger snap!
🚫 This tool is an alpha version and should not be used.
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
.
composer install
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
The configuration is written in yaml, it has three main entries.
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
This part describes how to connect to mysql. see PDO::__construct in order to see how to configure it more deeply
for now only one option exists:
exclude_missing_tables
: whether non mapped table should be dumped or ignored.
This entry lets you configure special cases:
- ignore tables:
exclude: true
- special values for columns
- empty value:
empty: true
- fake value :
faker: company
- empty value:
- preserve some rows from being faked
preserve_filter
- in this case, you need to provide both the
preserve
and thereverse
filter. They will be applied as SQL WHERE clauses.
- in this case, you need to provide both the
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)
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_.*"
).
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]
).