graze/sprout

Seed data for your project

0.4.4 2021-07-01 18:24 UTC

This package is auto-updated.

Last update: 2021-12-31 00:36:05 UTC


README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score PHP Version Docker Image Size Docker Pulls

Sprout is a tool to help Dump, Truncate and Seed development data into your databases.

fun image

  1. Seed sql data from local files
  2. Dump data from mysql tables
  3. Performs actions in parallel
  4. Handle multiple groups of seed data (for example, static, core, testing)

Install

Via Composer

composer require graze/sprout

Via docker

docker run -v [volumes] --rm graze/sprout [command]

Usage

See the full documentation for complete usage information.

File Structure

Sprout will use the following file structure by default, you can change the root and each group's path in the configuration file.

- /seed
  - group1
    - schema1
      - table1.sql
      - table2.sql
    - schema2
      - table3.sql
  - group1
    - schema3
      - table4.sql

Quick Start

# Dump all tables you are interested in
sprout dump --config=config/sprout.yml --group=static a_schema:table_1,table_2 ...

# Store the data in your repository of choice
git add /seed/static/*

# Seed the data from your local files
sprout seed --config=config/sprout.yml --group=static

Seeding

sprout seed [--config=<path>] [--group=<group>] [--no-chop|--chop-all] [<schema>[:<table>,...]] ...

sprout seed --config=config/sprout.yml the_schema
sprout seed --config=config/sprout.yml --chop-all the_schema
sprout seed --config=config/sprout.yml --no-chop the_schema

sprout seed --config=config/sprout.yml the_schema:country
sprout seed --config=config/sprout.yml --no-chop the_schema:country other_schema:planets

sprout seed --config=config/sprout.yml --group=core
sprout seed --config=config/sprout.yml --group=core the_schema
sprout seed --config=config/sprout.yml --no-chop --group=extra
sprout seed --config=config/sprout.yml --chop-all --group=extra

Truncating the data from all the tables in a schema

sprout chop [--config=<path>] [--group=<group>] [--all] [<schema>[:<table>,...]] ...

sprout chop --config=config/sprout.yml the_schema
sprout chop --config=config/sprout.yml the_schema:country
sprout chop --config=config/sprout.yml --all the_schema

sprout chop --config=config/sprout.yml --group=core the_schema
sprout chop --config=config/sprout.yml --group=extra the_schema:country
sprout chop --config=config/sprout.yml --group=extra --all

Dumping the data from all tables in a schema

sprout dump [--config=<path>] [--group=<group>] [<schema>[:<table>,...]] ...

sprout dump --config=config/sprout.yml the_schema
sprout dump --config=config/sprout.yml the_schema:country

sprout dump --config=config/sprout.yml --group=core
sprout dump --config=config/sprout.yml --group=core the_schema:country

Configuration

The configuration file follows the following standards.

By default sprout looks for a config/sprout.yml file, you can specify a different file using --config=path/to/file.yml.

defaults:
  group: core
  # default path
  path: /seed
  # number of simultaneous processors to run at a time (default: 10)
  simultaneousProcesses: 10

# ability to specify custom paths for groups
groups:
  core:
    path: /custom/path/to/group

schemas:
  # name of the schema to reference
  <name>:
    # [optional] the actual name of the schema in the database. If not specified, <name> from above will be used
    schema: 'schema'

    # Connection details - this is just an example, you may want to specify
    # different properties, e.g. if connecting to a remote server. You are
    # advised to refer to the 'pdo' documentation for further details.
    connection:
      user: 'morphism'
      password: 'morphism'
      # driver for the database connection, currently only: `mysql` is supported
      driver: 'mysql'
      # [optional] name of the database
      dbName: 'schema'
      # database on a remote host
      host: 'db'
      # [optional] port to use, by default: 3306
      port: 3306

Testing

make build test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email security@graze.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.