npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

sync-solution

v1.1.2

Published

Synchronize DDL changes across PostgreSQL databases using RabbitMQ

Readme

🛰️ sync-solution

sync-solution is an npm package that synchronizes PostgreSQL schema changes (DDL) across multiple databases using RabbitMQ.

It automatically:

  • Listens for schema changes in your master database
  • Stores changes as versioned migration files
  • Publishes migrations via RabbitMQ
  • Applies migrations to your remote databases

This ensures all databases stay in sync — reliably and asynchronously.


✨ Features

  • 🔍 Detects DDL changes in PostgreSQL automatically
  • 📂 Saves migrations in db/migrations/*.sql
  • 📤 Publishes schema changes to RabbitMQ queues
  • 📥 Consumes and applies migrations on multiple remote databases
  • 🔄 Retry-safe: failed migrations remain in the queue until successful
  • 🚀 One command runs everything (listener, producer, consumers)
  • 🛠️ Configurable via sync-solution.config.js

📦 Installation

Global install (inside a project):

npm install sync-solution

Run with:

npx sync-solution

⚙️ Configuration

Create a file called sync-solution.config.js in your project root:

// sync-solution.config.js
export default {
  rabbitmqUrl: "amqp://localhost",

  masterDb: {
    nickname: "masterDB",
    user: "postgres",
    host: "127.0.0.1",
    database: "main_db",
    password: "password",
    port: 5432
  },

  remoteDbs: [
    {
      nickname: "replica1",
      user: "postgres",
      host: "127.0.0.1",
      database: "replica_db1",
      password: "password",
      port: 5432
    },
    {
      nickname: "replica2",
      user: "postgres",
      host: "127.0.0.1",
      database: "replica_db2",
      password: "password",
      port: 5432
    }
  ],

  // Base queue name (one queue per remote DB will be created)
  queueName: "ddl_sync"
};

🚀 Usage

Start sync services (listener + producer + consumers):

sync-solution

That’s it! 🎉

  • Any schema changes in your master DB will be captured.
  • Migration files will be saved under db/migrations/.
  • Changes will be queued in RabbitMQ.
  • Remote DBs will apply them automatically.

🏗️ How It Works

          ┌───────────────┐
          │   Master DB   │
          │ (LISTEN DDL)  │
          └───────┬───────┘
                  │
        [listener + producer]
                  │
                  ▼
          ┌───────────────┐
          │   RabbitMQ    │
          │ (queues)      │
          └───────┬───────┘
          ┌───────┴───────┐
          ▼               ▼
   [consumer DB1]    [consumer DB2]
   (apply DDL)       (apply DDL)

📂 Project Structure

If you install locally, you’ll see something like this:

bin/
  sync-solution.js   # CLI entry point
src/
  db/                # database connection & setup
  helpers/           # helper functions
  listener.js        # listens for schema changes
  queue/             # producer & consumer
  configLoader.js    # loads sync-solution.config.js
  index.js           # unified runner

Migrations will be generated in your project under:

db/migrations/
  2025-08-05T12-34-56_create_table_users.sql
  2025-08-05T12-35-10_alter_table_orders.sql

🧪 Example

  1. Start PostgreSQL and RabbitMQ locally
  2. Create sync-solution.config.js
  3. Run:
sync-solution
  1. In your master DB, run:
CREATE TABLE test_sync (id SERIAL PRIMARY KEY, name TEXT);
  1. You’ll see:
[Server] Listening for schema changes...
[DDL] Change detected: CREATE TABLE test_sync ...
[Producer] Enqueued migration → replica1
[Producer] Enqueued migration → replica2
[Consumer:replica1] Applied migration ✔
[Consumer:replica2] Applied migration ✔
  1. Both remote DBs now have the new table 🎉

🛠️ Development

Clone and link globally for testing:

git clone https://github.com/your-username/sync-solution.git
cd sync-solution
npm install
npm link

Now you can run:

sync-solution

🐞 Troubleshooting

  • Error: Missing sync-solution.config.js → Make sure the config file exists in your project root.

  • Consumers stuck, migrations not applied → Check if RabbitMQ is running and reachable.

  • Migration fails on remote DB → The migration stays in queue until fixed. Review logs and apply manually if needed.


🤝 Contributing

  1. Fork this repo
  2. Create a feature branch
  3. Commit your changes
  4. Open a Pull Request

📜 License

MIT © Yazan I. Alfarra