PHPackages                             dibakar/db-sync - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. dibakar/db-sync

ActiveLibrary[Database &amp; ORM](/categories/database)

dibakar/db-sync
===============

A Laravel package for database synchronization with support for migrations and SQL imports

1.0.0(8mo ago)02MITPHPPHP ^8.1

Since Sep 18Pushed 8mo agoCompare

[ Source](https://github.com/dibakarmitra/db-sync)[ Packagist](https://packagist.org/packages/dibakar/db-sync)[ RSS](/packages/dibakar-db-sync/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (2)Used By (0)

Laravel DB Sync
===============

[](#laravel-db-sync)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d86f4b250b61cf0ed8bb366809ec56e587b099167ade9eb53cf0fa46034807b8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f646962616b61722f64622d73796e632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dibakar/db-sync)[![Total Downloads](https://camo.githubusercontent.com/992bad45c2a34be7be43898d9565f314b6715e555c64f79fa6920a4debf48343/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f646962616b61722f64622d73796e632e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dibakar/db-sync)[![License](https://camo.githubusercontent.com/3bdac35d45cf474146d0bf28e792721e34eb6c6a2dceeed28342b9447f9fd774/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f646962616b61722f64622d73796e633f7374796c653d666c61742d737175617265)](https://github.com/dibakar/db-sync)[![PHP Version](https://camo.githubusercontent.com/2cb94e081ba371adf3bbf468036cbea44f2b31d44480109557c274cd9cfb4db6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f646962616b61722f64622d73796e633f7374796c653d666c61742d737175617265)](https://php.net/)[![Laravel Version](https://camo.githubusercontent.com/2c2e7fd557d019700c2adeef5aae485f8957d6c1669585a3a096fbf3d0cebd95/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d392e7825323025374325323031302e7825323025374325323031312e782d6f72616e67653f7374796c653d666c61742d737175617265)](https://laravel.com/)

A powerful Laravel package for database synchronization, migration, and SQL file import operations. This package provides a unified interface to manage your database schema and data across different environments with ease and confidence.

✨ Features
----------

[](#-features)

- **Flexible Database Operations**: Supports various database operations including migrations, fresh migrations, and refresh operations
- **SQL File Import**: Import SQL files or directories of SQL files directly
- **Multiple Database Connections**: Work with different database connections easily
- **Progress Tracking**: Option to show progress for long-running operations
- **Production Safety**: Includes safety checks for production environments
- **Seeding Support**: Run seeders after migration/import operations
- **Configurable**: Customize behavior through configuration file
- **Logging**: Detailed logging of all operations

🚀 Installation
--------------

[](#-installation)

### Requirements

[](#requirements)

- PHP 8.1 or higher
- Laravel 9.x or later
- Composer

### Install via Composer

[](#install-via-composer)

```
composer require dibakar/db-sync
```

### Configuration (Optional)

[](#configuration-optional)

Publish the configuration file to customize the package behavior:

```
php artisan vendor:publish --provider="Dibakar\DbSync\DbSyncServiceProvider" --tag="db-sync-config"
```

This will create a `db-sync.php` file in your `config` directory with sensible defaults.

📦 Version Compatibility
-----------------------

[](#-version-compatibility)

LaravelPHPPackage11.x8.2+^1.010.x8.2+^1.09.x8.1+^1.0🚀 Quick Start
-------------

[](#-quick-start)

### Basic Usage

[](#basic-usage)

Run database synchronization with default settings:

```
php artisan db:sync
```

### Common Examples

[](#common-examples)

```
# Run with a specific database connection
# Import SQL files
php artisan db:sync --mode=import --path=/path/to/file.sql

# Import directory of SQL files
php artisan db:sync --mode=import --path=/path/to/sql/files

# Import with fresh database (drop all tables first)
php artisan db:sync --mode=import-fresh --path=/path/to/schema.sql

# Run migrations and seeders
php artisan db:sync --mode=migrate --seed

# Perform a fresh migration (drop all tables and re-run migrations)
php artisan db:sync --mode=migrate-fresh --seed

# Refresh migrations (rollback and re-run)
php artisan db:sync --mode=migrate-refresh --seed

# Append SQL to existing database
php artisan db:sync --mode=import-append --path=/path/to/data.sql

# Force operations in production (use with caution!)
php artisan db:sync --mode=migrate-fresh --force
```

📚 Documentation
---------------

[](#-documentation)

### Available Commands

[](#available-commands)

#### Basic Command Structure

[](#basic-command-structure)

```
php artisan db:sync [options]
```

#### Command Options

[](#command-options)

OptionDescriptionTypeDefault`--path`Path to a migration file, SQL file, or directory`string``null``--mode`Operation mode (see Modes section below)`string``import``--database`Database connection to use`string``config('database.default')``--force`Skip production confirmation`flag``false``--step`Show progress for each operation`flag``false``--seed`Run seeders after migration/import`flag``false``--no-interaction`Disable interactive prompts`flag``false`### Operation Modes

[](#operation-modes)

ModeDescriptionUse Case`import`Import SQL files without running migrationsInitial data import, data migration`import-fresh`Drop all tables and import SQL filesFresh installation, complete database reset`import-append`Append SQL to existing databaseData updates, incremental imports`migrate`Run database migrationsStandard migration updates`migrate-fresh`Drop all tables and run migrationsComplete database refresh`migrate-refresh`Rollback and re-run all migrationsDevelopment environment updates### Configuration

[](#configuration)

After publishing the configuration file, you can customize the package behavior:

```
return [
    /*
    |--------------------------------------------------------------------------
    | Default Database Connection
    |--------------------------------------------------------------------------
    |
    | This option controls the default database connection that will be used
    | by the package when none is specified via the --database option.
    |
    */
    'default_connection' => env('DB_CONNECTION', 'mysql'),

    /*
    |--------------------------------------------------------------------------
    | SQL Import Settings
    |--------------------------------------------------------------------------
    |
    | These options control how SQL files are processed during import.
    |
    */
    'sql' => [
        'max_execution_time' => 0, // 0 = no limit
        'query_logging' => true,
        'transaction' => true, // Wrap imports in a transaction
    ],
];
```

🛠 Advanced Usage
----------------

[](#-advanced-usage)

### Using in Code

[](#using-in-code)

You can also use the package directly in your code:

```
use Dibakar\DbSync\DbSync;

// Initialize with default options
$dbSync = app(DbSync::class);

// Run synchronization programmatically
$result = $dbSync->sync([
    'mode' => 'migrate',
    'database' => 'mysql',
    'seed' => true,
    'force' => false,
]);

// Handle the result
if ($result['success']) {
    echo "Database synchronized successfully!\n";
} else {
    echo "Error: " . $result['message'] . "\n";
}
```

🔒 Security
----------

[](#-security)

### Best Practices

[](#best-practices)

1. **Always** test database operations in a development environment first
2. **Always** take backups before running destructive operations
3. Use the `--force` flag with extreme caution in production
4. For large databases, use `--step` to monitor progress
5. Review SQL files from untrusted sources before importing
6. Use database transactions when possible

### Reporting Security Issues

[](#reporting-security-issues)

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

🤝 Contributing
--------------

[](#-contributing)

Thank you for considering contributing to Laravel DB Sync! The contribution guide can be found in the [CONTRIBUTING.md](CONTRIBUTING.md) file.

### Code of Conduct

[](#code-of-conduct)

In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](CODE_OF_CONDUCT.md).

### Testing

[](#testing)

```
composer test
```

📄 License
---------

[](#-license)

Laravel DB Sync is open-sourced software licensed under the [MIT license](LICENSE).

✨ Credits
---------

[](#-credits)

- [Dibakar](https://github.com/dibakarmitra)
- [All Contributors](../../contributors)

🔗 Useful Links
--------------

[](#-useful-links)

- [Laravel Documentation](https://laravel.com/docs)
- [Laravel Database Migrations](https://laravel.com/docs/migrations)
- [Packagist](https://packagist.org/packages/dibakar/db-sync)
- [GitHub Repository](https://github.com/dibakarmitra/db-sync)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance62

Regular maintenance activity

Popularity2

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

243d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/86a27be24348bc28aeefb406a99e47d6ee111f76a06b8f5e1371ae9745462bc9?d=identicon)[dibakar](/maintainers/dibakar)

---

Tags

db-syncimport-sqllaravellaravel-import-sqllaravelmigrationsdb-syncdatabase-syncsql-imports

### Embed Badge

![Health badge](/badges/dibakar-db-sync/health.svg)

```
[![Health](https://phpackages.com/badges/dibakar-db-sync/health.svg)](https://phpackages.com/packages/dibakar-db-sync)
```

###  Alternatives

[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[baril/bonsai

An implementation of the Closure Tables pattern for Eloquent.

3593.5k](/packages/baril-bonsai)[toponepercent/baum

Baum is an implementation of the Nested Set pattern for Eloquent models.

3154.7k](/packages/toponepercent-baum)[dragon-code/laravel-data-dumper

Adding data from certain tables when executing the `php artisan schema:dump` console command

3418.6k](/packages/dragon-code-laravel-data-dumper)[orptech/laravel-migration-partition

Laravel extensions that extends Illuminate to enable partitioned table creation within Laravel migrations.

3426.7k](/packages/orptech-laravel-migration-partition)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
