Download the PHP package mb4it/laravel-dbtodb-migration without Composer

On this page you can find all versions of the php package mb4it/laravel-dbtodb-migration. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-dbtodb-migration

mb4it/laravel-dbtodb-migration

English | Русский

Laravel 12 package: an Artisan command that copies rows from one configured database connection to one or more target tables on another connection. Runs are driven by named migrations in config/dbtodb_mapping.php, with chunked reads, optional keyset pagination, per-target column maps and transforms, filters, upsert vs insert, strict validation, JSON reports, and optional profiling logs.

Requirements

Installation

Define the database connections referenced by your migrations in config/database.php.

Supported target drivers

Target-table metadata resolution, required-column validation, and automatic primary-key detection are supported for these Laravel target connection drivers:

Table prefixes configured on the target connection are honored when reading target metadata.

Quick start

Use this path when you only need to copy a few columns from one source table into one target table. The command uses migrations.default when --migration is omitted, so a simple run does not need --source or --target once the migration defines them.

  1. Install and publish the package config:

  2. Add the source and target Laravel database connections in config/database.php (for example legacy_mysql and pgsql_app).

  3. Edit config/dbtodb_mapping.php and replace the published example with a default migration:

  4. Run a safe validation pass first. --dry-run reads data, applies filters/transforms, validates target columns in strict mode, and writes only the JSON report:

  5. If the report looks correct, run the migration for real:

  6. For production-sized data, prefer adding keyset_column and an explicit chunk size in the full table syntax below.

Documentation coverage and safety notes

This README documents the public configuration surface for the current migration-centric format: installation, supported drivers, quick start, named migrations, ordered steps, CLI options, runtime/memory settings, automatic target-type transforms, profile logging, sequence synchronization, filters, column transforms, fan-out/fan-in routing, and edge-case behavior. Before running against production data, review the target schema, run --dry-run, keep strict enabled unless you intentionally want looser validation, and store the generated JSON report for audit/debugging.

The package no longer accepts the older top-level tables / columns / filters config shape; use migrations.<name> for every run.

Complete complex config example

The example below shows a production-oriented config/dbtodb_mapping.php with global runtime defaults, auto transforms, ordered steps, source SQL filters, target routing filters, transforms, deduplication, mixed write operations, and sequence synchronization. It assumes that the Laravel connections legacy_mysql and pgsql_app already exist in config/database.php, and that target tables/columns match the mapped payloads.

Named migrations

Add as many migrations as you need under the top-level migrations node. Select one with --migration=name.

--source and --target are still available as overrides for local/debug runs, but normal migrations should define source and target in config.

Full table syntax

Use the short syntax for simple column maps. Switch to the full target definition when you need source/target filters, transforms, upsert keys, operation, deduplication, row-error handling, or source runtime settings. Supported target operations are upsert, insert, and truncate_insert (truncate_insert clears each target table once per run before the first write).

Ordered steps

A migration can contain ordered steps. Omit --step to run all steps in order, or pass --step=name to run one step.

Command options

Option Default Description
--migration= default Named migration from dbtodb_mapping.migrations. When omitted, migrations.default is used.
--tables= all source tables in selected migration/step Comma-separated source table names.
--step= all steps Run one step from the selected migration.
--source= migration source Override source connection.
--target= migration target Override target connection.
--dry-run off Validate and read without writing.
--continue-on-error off Continue after per-pipeline failures.
--report-file= timestamped file in storage/logs Write JSON report.
--profile off Log timings to dbtodb_mapping.profile_logging.

Runtime and memory

Global defaults live in runtime.defaults; a migration may override them with migrations.{name}.runtime.defaults, and a source table may override chunk, transaction_mode, and keyset_column in its source definition.

Key Default Purpose
runtime.defaults.chunk 500 Rows read per chunk.
runtime.defaults.max_rows_per_upsert 500 Cap on rows per insert/upsert statement. The writer also auto-splits batches that would exceed PostgreSQL's 65535 placeholder limit, so max_rows_per_upsert mostly controls statement size, not correctness.
runtime.defaults.transaction_mode 'batch' batch wraps each chunk write in one transaction (efficient). atomic wraps the entire pipeline in a single transaction — all targets must share one connection, otherwise the run fails fast.
runtime.memory.memory_log_every_chunks 0 (off) When >0, logs memory_get_usage() every N chunks via the profile channel.
runtime.memory.force_gc_every_chunks 20 Calls gc_collect_cycles() every N chunks. Set to 0 to disable.
runtime.profile_slow_chunk_seconds 5.0 Chunks slower than this are tagged slow: true in profile logs.
runtime.cli_memory_limit unset When set (e.g. '1G'), passes the value to ini_set('memory_limit', …) at command start.

A source table can opt in to keyset pagination by setting keyset_column (e.g. 'id'). Requirements: the column must be present in the source SELECT (the resolver adds it automatically when you use a column map), it must be sortable, and values should be unique and monotonically increasing — otherwise rows can be skipped or duplicated across chunks. Without keyset_column, the reader falls back to offset pagination.

Auto transforms

The package coerces values to match common target column shapes after your transforms run. Configure under auto_transforms:

Auto transforms run after explicit column transforms and use resolved target-table metadata. bool casting accepts 1, true, 'true', '1', 'yes', 'on' (and their false counterparts). Empty strings become null only when empty_string_to_null is enabled and the target column is nullable. Invalid JSON strings are kept by default; set json_invalid to null or fail for stricter behavior.

Profile logging and sequence sync

Filters

Source filters support: =, !=, >, >=, <, <=, in, not_in, like, not_like, null, not_null, between, not_between, exists_in, where_column, date, year, and month. Filters may be written as a simple associative map, a list of rule arrays, nested and / or groups, or a PHP callable that receives the source Illuminate\Database\Query\Builder.

Source and target filters run at different stages:

  1. Source filters are applied to the SQL query before rows are read from the source database. They reduce the shared input set for the whole source-table pipeline.
  2. Target filters are evaluated in PHP for each target, after a row has passed source filters and before target column mapping/transforms. They do not query the target table and do not see transformed target values; they inspect the original source row that was read. Use target filters for fan-out/routing, for example: write every active user to users, but only source rows with is_admin = 1 to admins.

Target filters use the same DSL where it can be evaluated against the PHP source row. exists_in is SQL-only and is rejected for target filters with a clear validation error. Builder callables are source-only and should not be used for target filters.

Complex source filter example:

Builder callback source filter example (runtime PHP config only; do not use closures if you rely on Laravel config:cache):

Equivalent target/PHP filters can use nested groups and row-level operators. In a target definition, these rules filter the rows already selected by source.filters for that one target only:

Column transforms

Transforms are keyed by target column in the target definition.

Supported string rules: trim, null_if_empty, zero_date_to_null, lower, upper, and slug.

Supported array rules:

Closures and invoke callables receive the current value, full source row, source column, target column, and target table: (mixed $value, array $sourceRow, ?string $sourceColumn, ?string $targetColumn, ?string $targetTable) => mixed. Two-argument closures (fn ($value, $row) => …) remain compatible.

lookup caches results per DbToDbTransformEngine instance for the lifetime of one command run. The cache is keyed by (connection, table, key column, value column, lookup value), so high-cardinality lookups grow memory linearly with distinct values. For very large fan-outs, prefer denormalising on the source side or use invoke with your own bounded cache.

Routing patterns

Fan-out (1 source → N targets)

Each target reads the same source row but applies its own filters/transforms/operation. When a source maps to more than one target, every target must declare a non-empty columns map.

Fan-in (N sources → 1 target) with static columns

Two source tables write into the same target table. Use a static transform to mark the origin per pipeline.

Because transforms only fire for columns produced by the column map, the recipe above wires any source column into the target column you want to fill statically. The static transform discards the mapped value and writes the literal.

Behavior reference

These semantics are not always obvious; lock them in before writing migrations against production data:

Developing this package

License

MIT. See LICENSE.


All versions of laravel-dbtodb-migration with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
laravel/framework Version ^v12
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mb4it/laravel-dbtodb-migration contains the following files

Loading the files please wait ...