0.0.8 • Published 2 years ago
@hassanzhd/replica-db v0.0.8
replicaDB
What is replicaDB?
replicaDB is a tool that allows you to replicate databases without:
- 📝 Writing any SQL.
- Ɩ Worrying about type mapping.
- 📖 Creating any database dumps or archives
- 💻 Interacting with any sort of UI.
What is required?
All you need is a config.yaml file and replicaDB installed as an npm package.
Features:
replicaDB provides multi engine support that replicates databases even with engine differences 😱
Following mappings are currently supported:
Source Destination mysql mysql postgres postgres mysql postgres postgres mysql Replicas are created on destination with:
- Same table names
- Same table schemas
- Records part of table
Supported types:
mysql->postgres, postgres->mysql mapping:
| Sno. | mysql type | postgres type |
|---|---|---|
| 1 | smallint | smallint |
| 2 | bigint | bigint |
| 3 | text | text |
| 4 | varchar | varchar |
| 5 | numeric | numeric |
| 6 | char | char |
| 7 | boolean | tinyint(1) |
| 8 | timestamp without time zone | datetime |
| 9 | timestamp with time zone | timestamp |
| 10 | time without time zone | time |
postgres->mysql mapping:
| Sno. | postgres type | mysql type |
|---|---|---|
| 1 | integer | int |
| 2 | uuid | varchar(36) |
| 2 | bigserial | bigint |
Config file schema:
source:
engine: mysql
host: HOST
database: DATABASE_NAME
port: PORT_NUMBER
user: USER
password: PASSWORD
destination:
engine: postgres
host: HOST
database: DATABASE_NAME
port: PORT_NUMBER
user: USER
password: PASSWORDnote: engine key can only contain mysql or postgres
Installation:
You can install the package by the following command:
npm i @hassanzhd/replica-dbUsage:
npx replica-db -f <PATH_TO_CONFIG.YAML>Limitations:
Currently replicaDB works with the following known limitations:
- Postgres tables part of
"public"schema can only be replicated - Constraints supported include:
- PRIMARY KEY
- Only tables are replicated, this doesn't include views, stored procedures, etc.
Queries / Feedback:
For any queries, request or feedback please feel free to create an issue