db-model-router 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +150 -11
- package/TODO.md +0 -15
- package/db-manager/.dbmanager.sqlite +0 -0
- package/db-manager/README.md +223 -0
- package/db-manager/adapter-proxy.js +361 -0
- package/db-manager/demo/cockroachdb.env +6 -0
- package/db-manager/demo/demo.sqlite +0 -0
- package/db-manager/demo/dynamodb.env +7 -0
- package/db-manager/demo/mongodb.env +4 -0
- package/db-manager/demo/mssql.env +6 -0
- package/db-manager/demo/mysql.env +6 -0
- package/db-manager/demo/oracle.env +6 -0
- package/db-manager/demo/postgres.env +6 -0
- package/db-manager/demo/redis.env +4 -0
- package/db-manager/demo/seeds/cockroachdb.sql +32 -0
- package/db-manager/demo/seeds/mssql.sql +32 -0
- package/db-manager/demo/seeds/mysql.sql +32 -0
- package/db-manager/demo/seeds/oracle.sql +43 -0
- package/db-manager/demo/seeds/postgres.sql +32 -0
- package/db-manager/demo/seeds/sqlite3.sql +32 -0
- package/db-manager/demo/sqlite3.env +2 -0
- package/db-manager/metadata-db.js +170 -0
- package/db-manager/public/.gitkeep +1 -0
- package/db-manager/public/css/style.css +1413 -0
- package/db-manager/public/js/app.js +1370 -0
- package/db-manager/routes/api.js +388 -0
- package/db-manager/routes/views.js +61 -0
- package/db-manager/server.js +39 -0
- package/db-manager/utils/build-filter-config.js +18 -0
- package/db-manager/utils/csv-export.js +59 -0
- package/db-manager/utils/export-filename.js +39 -0
- package/db-manager/utils/filter-tables.js +20 -0
- package/db-manager/utils/parse-filters.js +93 -0
- package/db-manager/utils/sort-state.js +35 -0
- package/db-manager/views/.gitkeep +1 -0
- package/db-manager/views/dashboard.ejs +53 -0
- package/db-manager/views/history.ejs +52 -0
- package/db-manager/views/index.ejs +35 -0
- package/db-manager/views/layout.ejs +31 -0
- package/db-manager/views/partials/data-panel.ejs +74 -0
- package/db-manager/views/partials/header.ejs +36 -0
- package/db-manager/views/partials/sidebar.ejs +30 -0
- package/db-manager/views/query.ejs +58 -0
- package/dbmr.schema.json +22 -44
- package/demo/.dockerignore +7 -0
- package/demo/.env.example +15 -0
- package/demo/Dockerfile +20 -0
- package/demo/app.js +39 -0
- package/demo/commons/add_migration.js +43 -0
- package/demo/commons/db.js +17 -0
- package/demo/commons/migrate.js +68 -0
- package/demo/commons/modules.js +18 -0
- package/demo/commons/password.js +36 -0
- package/demo/commons/security.js +30 -0
- package/demo/commons/session.js +13 -0
- package/demo/commons/webhook.js +81 -0
- package/demo/dbmr.schema.json +338 -0
- package/demo/middleware/authenticate.js +14 -0
- package/demo/middleware/hasPermission.js +30 -0
- package/demo/middleware/logger.js +67 -0
- package/demo/middleware/tenantIsolation.js +19 -0
- package/demo/migrations/20260510092158_create_migrations_table.sql +6 -0
- package/demo/migrations/20260510092159_create_saas_tables.sql +69 -0
- package/demo/migrations/20260510092159_create_tables.sql +193 -0
- package/demo/models/addresses.js +24 -0
- package/demo/models/cart_items.js +20 -0
- package/demo/models/carts.js +18 -0
- package/demo/models/categories.js +22 -0
- package/demo/models/coupons.js +25 -0
- package/demo/models/index.js +43 -0
- package/demo/models/order_items.js +23 -0
- package/demo/models/orders.js +27 -0
- package/demo/models/payments.js +23 -0
- package/demo/models/product_images.js +20 -0
- package/demo/models/product_reviews.js +22 -0
- package/demo/models/product_variants.js +22 -0
- package/demo/models/products.js +32 -0
- package/demo/models/role_permissions.js +17 -0
- package/demo/models/roles.js +17 -0
- package/demo/models/shipments.js +21 -0
- package/demo/models/tenants.js +18 -0
- package/demo/models/users.js +23 -0
- package/demo/models/webhook_logs.js +22 -0
- package/demo/models/webhooks.js +19 -0
- package/demo/models/wishlists.js +17 -0
- package/demo/openapi.json +7000 -0
- package/demo/package-lock.json +2827 -0
- package/demo/package.json +42 -0
- package/demo/routes/addresses/index.js +10 -0
- package/demo/routes/auth/index.js +55 -0
- package/demo/routes/carts/cart_items/index.js +11 -0
- package/demo/routes/carts/index.js +14 -0
- package/demo/routes/categories/index.js +10 -0
- package/demo/routes/coupons/index.js +10 -0
- package/demo/routes/docs.js +18 -0
- package/demo/routes/health.js +35 -0
- package/demo/routes/index.js +54 -0
- package/demo/routes/orders/index.js +18 -0
- package/demo/routes/orders/order_items/index.js +11 -0
- package/demo/routes/orders/payments/index.js +11 -0
- package/demo/routes/orders/shipments/index.js +11 -0
- package/demo/routes/products/index.js +18 -0
- package/demo/routes/products/product_images/index.js +11 -0
- package/demo/routes/products/product_reviews/index.js +11 -0
- package/demo/routes/products/product_variants/index.js +11 -0
- package/demo/routes/roles/index.js +75 -0
- package/demo/routes/roles/permissions/index.js +47 -0
- package/demo/routes/tenants/index.js +45 -0
- package/demo/routes/users/index.js +45 -0
- package/demo/routes/wishlists/index.js +10 -0
- package/demo/seeds/saas-seed.js +329 -0
- package/docker-compose.yml +61 -0
- package/package.json +120 -113
- package/scripts/demo-create.js +1 -1
- package/skill/SKILL.md +119 -3
- package/src/cli/commands/db-manager.js +134 -0
- package/src/cli/commands/generate.js +106 -60
- package/src/cli/commands/help.js +0 -1
- package/src/cli/generate-route.js +66 -27
- package/src/cli/generate-saas-structure.js +129 -0
- package/src/cli/init/dependencies.js +1 -1
- package/src/cli/init/generators.js +6 -77
- package/src/cli/init.js +9 -2
- package/src/cli/main.js +8 -1
- package/src/cli/saas/generate-saas-middleware.js +110 -0
- package/src/cli/saas/generate-saas-migrations.js +480 -0
- package/src/cli/saas/generate-saas-models.js +211 -0
- package/src/cli/saas/generate-saas-openapi.js +419 -0
- package/src/cli/saas/generate-saas-routes.js +435 -0
- package/src/cli/saas/generate-saas-seeds.js +243 -0
- package/src/cli/saas/generate-saas-tests.js +473 -0
- package/src/cli/saas/generate-saas-utils.js +176 -0
- package/src/commons/kafka.js +139 -0
- package/src/commons/model.js +29 -9
- package/src/commons/route.js +6 -6
- package/src/index.js +2 -0
- package/src/mssql/db.js +41 -3
- package/src/mysql/db.js +3 -0
- package/src/postgres/db.js +6 -0
- package/src/cli/generate-db-manager.js +0 -1573
package/README.md
CHANGED
|
@@ -373,21 +373,38 @@ db-model-router inspect --type mysql --json
|
|
|
373
373
|
|
|
374
374
|
Generate models, routes, tests, OpenAPI spec, and LLM docs from a schema file. All generated code is ESM (`import`/`export`).
|
|
375
375
|
|
|
376
|
-
| Flag / Arg
|
|
377
|
-
|
|
|
378
|
-
| `--from <path>`
|
|
379
|
-
| `--models`
|
|
380
|
-
| `--routes`
|
|
381
|
-
| `--openapi`
|
|
382
|
-
| `--tests`
|
|
383
|
-
| `--
|
|
376
|
+
| Flag / Arg | Description |
|
|
377
|
+
| ------------------------ | ------------------------------------------------- |
|
|
378
|
+
| `--from <path>` | Path to schema file (default: `dbmr.schema.json`) |
|
|
379
|
+
| `--models=false` | Disable model file generation |
|
|
380
|
+
| `--routes=false` | Disable route file generation |
|
|
381
|
+
| `--openapi=false` | Disable OpenAPI spec generation |
|
|
382
|
+
| `--tests=false` | Disable test file generation |
|
|
383
|
+
| `--migrations=false` | Disable migration file generation |
|
|
384
|
+
| `--saas-structure=false` | Disable SaaS multi-tenant generation |
|
|
384
385
|
|
|
385
|
-
|
|
386
|
+
All artifact types are **enabled by default**. Use `--flag=false` to disable specific ones.
|
|
387
|
+
|
|
388
|
+
##### `--saas-structure` — SaaS Multi-Tenant Architecture (default: enabled)
|
|
389
|
+
|
|
390
|
+
The SaaS structure is always generated unless explicitly disabled with `--saas-structure=false`. It scaffolds a complete multi-tenant SaaS backend on top of your schema-generated code:
|
|
391
|
+
|
|
392
|
+
- **Tables**: `tenants`, `users`, `roles`, `role_permissions`, `webhooks`, `webhook_logs`
|
|
393
|
+
- **Middleware**: `authenticate`, `tenantIsolation`, `hasPermission`
|
|
394
|
+
- **Routes**: CRUD for users/tenants/roles/permissions + auth (login/logout)
|
|
395
|
+
- **Utilities**: password hashing (crypto.scrypt), modules registry, webhook delivery with retry
|
|
396
|
+
- **Seeds**: Super Admin user + Tenant Admin role template
|
|
397
|
+
- **Migrations**: Single consolidated migration file for all SaaS tables
|
|
398
|
+
|
|
399
|
+
> **Important**: Since `--saas-structure` is on by default, the tables `users`, `tenants`, `roles`, and `role_permissions` are already generated with their models, routes, and migrations. **Do not add these tables to your `dbmr.schema.json`** — they will be duplicated. Only define your product/domain-specific tables in the schema (e.g., `products`, `orders`, `invoices`).
|
|
400
|
+
|
|
401
|
+
The generated `routes/index.js` automatically combines both SaaS routes (under `/api/auth`, `/api/users`, `/api/tenants`, `/api/roles`) and your schema-generated product routes. The OpenAPI/Swagger docs include all SaaS endpoints with security annotations.
|
|
386
402
|
|
|
387
403
|
```bash
|
|
388
404
|
db-model-router generate --from dbmr.schema.json
|
|
389
|
-
db-model-router generate --
|
|
390
|
-
db-model-router generate --
|
|
405
|
+
db-model-router generate --tests=false --dry-run # skip tests
|
|
406
|
+
db-model-router generate --saas-structure=false # skip SaaS generation
|
|
407
|
+
db-model-router generate --openapi=false --tests=false # skip OpenAPI and tests
|
|
391
408
|
db-model-router generate --from dbmr.schema.json --json
|
|
392
409
|
```
|
|
393
410
|
|
|
@@ -429,6 +446,32 @@ db-model-router help init # detailed help for init
|
|
|
429
446
|
db-model-router init --help # same as above
|
|
430
447
|
```
|
|
431
448
|
|
|
449
|
+
## DB Manager
|
|
450
|
+
|
|
451
|
+
A built-in database management dashboard accessible via the CLI. Connects to any supported SQL database and provides a visual interface for browsing tables, editing data, running queries, and viewing history.
|
|
452
|
+
|
|
453
|
+
### Launch
|
|
454
|
+
|
|
455
|
+
```bash
|
|
456
|
+
db-model-router db-manager [--env .env] [--port 4000]
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
| Flag / Arg | Description |
|
|
460
|
+
| -------------- | --------------------------------------- |
|
|
461
|
+
| `--env <path>` | Path to `.env` file with DB credentials |
|
|
462
|
+
| `--port <n>` | Server port (default: 4000) |
|
|
463
|
+
|
|
464
|
+
### Features
|
|
465
|
+
|
|
466
|
+
- **Dashboard** — Overview of all tables with column count, index count, row count, and size
|
|
467
|
+
- **Table Browser** — Browse, filter, sort, add, edit, and delete rows with pagination
|
|
468
|
+
- **Query Editor** — Execute raw SQL queries with results table and CSV export
|
|
469
|
+
- **Query History** — View previously executed queries with timestamps
|
|
470
|
+
- **Theme Support** — Light, Dark, and System (auto-detect) modes with persistent preference
|
|
471
|
+
- **Filter System** — Column-level filters with operators (=, !=, like, not like, <, >, <=, >=)
|
|
472
|
+
- **Inline Editing** — Edit rows directly in the table without a separate form
|
|
473
|
+
- **CSV Export** — Export selected rows or query results to CSV
|
|
474
|
+
|
|
432
475
|
## MySQL Example
|
|
433
476
|
|
|
434
477
|
### 1. Connect
|
|
@@ -645,6 +688,102 @@ When using `GET /` (list endpoint), query parameters are automatically parsed in
|
|
|
645
688
|
- `IN` and `NOT IN` values are comma-separated inside parentheses.
|
|
646
689
|
Operators are detected in order of specificity: `!in(...)` → `in(...)` → `!%...%` → `%...%` → `>=` → `<=` → `>` → `<` → `!value` → `=` (default).
|
|
647
690
|
|
|
691
|
+
## Kafka Event Production
|
|
692
|
+
|
|
693
|
+
db-model-router has built-in Kafka support. When enabled, every write operation (insert, update, upsert, delete) automatically produces a Kafka event — one event per row affected.
|
|
694
|
+
|
|
695
|
+
### Setup
|
|
696
|
+
|
|
697
|
+
Install the Kafka driver:
|
|
698
|
+
|
|
699
|
+
```bash
|
|
700
|
+
npm install kafkajs
|
|
701
|
+
```
|
|
702
|
+
|
|
703
|
+
Set the `KAFKA_BROKER` environment variable in your `.env`:
|
|
704
|
+
|
|
705
|
+
```env
|
|
706
|
+
KAFKA_BROKER=localhost:9092
|
|
707
|
+
KAFKA_CLIENT_ID=my-app
|
|
708
|
+
KAFKA_TOPIC_PREFIX=dbmr
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
### Initialize
|
|
712
|
+
|
|
713
|
+
```js
|
|
714
|
+
const { init, db, kafka } = require("db-model-router");
|
|
715
|
+
|
|
716
|
+
init("postgres");
|
|
717
|
+
db.connect({ host: "localhost", database: "my_app" });
|
|
718
|
+
|
|
719
|
+
// Connect Kafka producer (only if KAFKA_BROKER is set)
|
|
720
|
+
await kafka.init();
|
|
721
|
+
```
|
|
722
|
+
|
|
723
|
+
Or with explicit options:
|
|
724
|
+
|
|
725
|
+
```js
|
|
726
|
+
await kafka.init({
|
|
727
|
+
broker: "localhost:9092",
|
|
728
|
+
clientId: "my-app",
|
|
729
|
+
topicPrefix: "dbmr",
|
|
730
|
+
});
|
|
731
|
+
```
|
|
732
|
+
|
|
733
|
+
### API
|
|
734
|
+
|
|
735
|
+
| Method | Description |
|
|
736
|
+
| --------------------------------------- | -------------------------------------------- |
|
|
737
|
+
| `kafka.init(opts)` | Connect producer. Returns `true` on success. |
|
|
738
|
+
| `kafka.disconnect()` | Graceful shutdown. |
|
|
739
|
+
| `kafka.produce(table, operation, data)` | Manually produce an event. |
|
|
740
|
+
| `kafka.status()` | Returns `true` if connected. |
|
|
741
|
+
|
|
742
|
+
### Event Format
|
|
743
|
+
|
|
744
|
+
Each affected row produces its own event to topic `{prefix}.{table_name}`:
|
|
745
|
+
|
|
746
|
+
```json
|
|
747
|
+
{
|
|
748
|
+
"table_name": "users",
|
|
749
|
+
"operation_type": "insert",
|
|
750
|
+
"data": { "id": 1, "name": "Alice", "email": "alice@example.com" },
|
|
751
|
+
"timestamp": "2026-05-09T12:00:00.000Z"
|
|
752
|
+
}
|
|
753
|
+
```
|
|
754
|
+
|
|
755
|
+
- `operation_type`: `"insert"`, `"update"`, `"upsert"`, or `"delete"`
|
|
756
|
+
- `data`: The affected row as an object (not an array)
|
|
757
|
+
- Bulk operations (e.g. inserting 100 rows) produce 100 individual events, batched efficiently
|
|
758
|
+
|
|
759
|
+
### Behavior
|
|
760
|
+
|
|
761
|
+
- If `KAFKA_BROKER` is not set, Kafka is completely disabled with zero overhead
|
|
762
|
+
- Events are produced after successful DB operations only
|
|
763
|
+
- Read operations (`find`, `list`, `byId`) never produce events
|
|
764
|
+
- Large batches are automatically chunked (500 messages per send) to stay within Kafka's message size limits
|
|
765
|
+
- Failed event production logs a warning but does not throw or affect the API response
|
|
766
|
+
|
|
767
|
+
### Docker
|
|
768
|
+
|
|
769
|
+
The included `docker-compose.yml` provides Zookeeper, Kafka, and Kafka UI:
|
|
770
|
+
|
|
771
|
+
```bash
|
|
772
|
+
docker compose up -d zookeeper kafka kafka-ui
|
|
773
|
+
```
|
|
774
|
+
|
|
775
|
+
| Service | Port | Description |
|
|
776
|
+
| --------- | ---- | --------------------------------- |
|
|
777
|
+
| Zookeeper | 2181 | Kafka coordination |
|
|
778
|
+
| Kafka | 9092 | Broker (host) / 29092 (internal) |
|
|
779
|
+
| Kafka UI | 8090 | Web dashboard for topics/messages |
|
|
780
|
+
|
|
781
|
+
### Testing
|
|
782
|
+
|
|
783
|
+
```bash
|
|
784
|
+
npm run test:kafka # uses env/.env.kafka (SQLite3 + Kafka broker)
|
|
785
|
+
```
|
|
786
|
+
|
|
648
787
|
## Switching Adapters
|
|
649
788
|
|
|
650
789
|
To use a different database, call `init()` before `db.connect()`:
|
package/TODO.md
CHANGED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
in generate --db-manager should generate
|
|
2
|
-
DB manager using ejs db manager in the generated codebase (dark theme)
|
|
3
|
-
There is login page with just password -> Needs to login status in session (req.session["db-manager"])
|
|
4
|
-
the password will be in .env as DATABASE_MANAGER_PASSWORD
|
|
5
|
-
Then db manager page
|
|
6
|
-
Left sidebar will have list of tables with local search
|
|
7
|
-
Main page will have 3 tabs
|
|
8
|
-
|
|
9
|
-
1. Table Structure
|
|
10
|
-
2. Data top 30 rows with filter,sort,pagenation
|
|
11
|
-
3. Query page where user can type the raw query
|
|
12
|
-
This needs to added in route like /database
|
|
13
|
-
|
|
14
|
-
The api that this will use is POST /database/login, GET /database/tables, GET /database/tables/:table_name?sort=1&size=30&post_name=%title%
|
|
15
|
-
the UI should be able to filter,sort and move through the pages
|
|
Binary file
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# DB Manager — Testing Guide
|
|
2
|
+
|
|
3
|
+
A live database management UI launched via `npx db-model-router db-manager`. This guide covers how to test it against each supported database using Docker.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- Docker and Docker Compose installed
|
|
8
|
+
- Node.js 18+
|
|
9
|
+
- npm dependencies installed (`npm install` from the project root)
|
|
10
|
+
|
|
11
|
+
## Quick Start (SQLite — no Docker needed)
|
|
12
|
+
|
|
13
|
+
SQLite requires no external services. Run these commands from the project root:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# Seed the demo SQLite database
|
|
17
|
+
sqlite3 ./db-manager/demo/demo.sqlite < ./db-manager/demo/seeds/sqlite3.sql
|
|
18
|
+
|
|
19
|
+
# Start the DB Manager
|
|
20
|
+
npx db-model-router db-manager --env ./db-manager/demo/sqlite3.env
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Open http://localhost:4000 in your browser.
|
|
24
|
+
|
|
25
|
+
## Testing with Docker Databases
|
|
26
|
+
|
|
27
|
+
### 1. Start Docker Services
|
|
28
|
+
|
|
29
|
+
From the project root, start all database containers:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Start all services
|
|
33
|
+
docker compose up -d
|
|
34
|
+
|
|
35
|
+
# Or start a specific service
|
|
36
|
+
docker compose up -d mysql
|
|
37
|
+
docker compose up -d postgres
|
|
38
|
+
docker compose up -d mssql
|
|
39
|
+
docker compose up -d mongodb
|
|
40
|
+
docker compose up -d redis
|
|
41
|
+
docker compose up -d cockroachdb
|
|
42
|
+
docker compose up -d oracle
|
|
43
|
+
docker compose up -d dynamodb
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Wait for the containers to be healthy:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
docker compose ps
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 2. Seed the Databases
|
|
53
|
+
|
|
54
|
+
Run the seed scripts to create sample tables (`users`, `products`) with test data.
|
|
55
|
+
|
|
56
|
+
#### MySQL
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
docker exec -i db-model-router-mysql mysql -uroot -ppassword test_db < ./db-manager/demo/seeds/mysql.sql
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
#### PostgreSQL
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
docker exec -i db-model-router-postgres psql -U postgres -d test_db < ./db-manager/demo/seeds/postgres.sql
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
#### MSSQL
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
docker exec -i db-model-router-mssql /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P "Password123!" -d master -C -i /dev/stdin < ./db-manager/demo/seeds/mssql.sql
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### CockroachDB
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
docker exec -i db-model-router-cockroachdb cockroach sql --insecure --database=defaultdb < ./db-manager/demo/seeds/cockroachdb.sql
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### Oracle
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
docker exec -i db-model-router-oracle sqlplus system/oracle@//localhost:1521/FREEPDB1 < ./db-manager/demo/seeds/oracle.sql
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
#### SQLite (no Docker)
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
sqlite3 ./db-manager/demo/demo.sqlite < ./db-manager/demo/seeds/sqlite3.sql
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
> **Note:** MongoDB, Redis, and DynamoDB do not use SQL seeds. They will work with the DB Manager once data is inserted through the UI.
|
|
93
|
+
|
|
94
|
+
### 3. Launch the DB Manager
|
|
95
|
+
|
|
96
|
+
Run from the project root. Use the `--env` flag to point to the appropriate demo env file.
|
|
97
|
+
|
|
98
|
+
#### MySQL
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npx db-model-router db-manager --env ./db-manager/demo/mysql.env
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### PostgreSQL
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
npx db-model-router db-manager --env ./db-manager/demo/postgres.env
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### MSSQL
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
npx db-model-router db-manager --env ./db-manager/demo/mssql.env
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
#### CockroachDB
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
npx db-model-router db-manager --env ./db-manager/demo/cockroachdb.env
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
#### Oracle
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
npx db-model-router db-manager --env ./db-manager/demo/oracle.env
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
#### MongoDB
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
npx db-model-router db-manager --env ./db-manager/demo/mongodb.env
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
#### Redis
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
npx db-model-router db-manager --env ./db-manager/demo/redis.env
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
#### DynamoDB
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
npx db-model-router db-manager --env ./db-manager/demo/dynamodb.env
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
#### SQLite
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
npx db-model-router db-manager --env ./db-manager/demo/sqlite3.env
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### 4. Custom Port
|
|
153
|
+
|
|
154
|
+
Use the `--port` flag to run on a different port:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
npx db-model-router db-manager --env ./db-manager/demo/postgres.env --port 5000
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## CLI Flags
|
|
161
|
+
|
|
162
|
+
| Flag | Default | Description |
|
|
163
|
+
| ----------------- | ------- | ------------------------------------------------ |
|
|
164
|
+
| `--env <path>` | `.env` | Path to the environment file with DB credentials |
|
|
165
|
+
| `--port <number>` | `4000` | Port for the web UI |
|
|
166
|
+
|
|
167
|
+
## Running Tests
|
|
168
|
+
|
|
169
|
+
From the project root:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
# Run all tests (unit + integration + property tests)
|
|
173
|
+
npm test
|
|
174
|
+
|
|
175
|
+
# Run only the DB Manager property tests
|
|
176
|
+
npx mocha test/properties/db-manager.property.test.js --timeout 15000 --exit
|
|
177
|
+
|
|
178
|
+
# Run only the DB Manager integration tests
|
|
179
|
+
npx mocha test/integration/db-manager-app.test.js --timeout 15000 --exit
|
|
180
|
+
|
|
181
|
+
# Run only the DB Manager CLI unit tests
|
|
182
|
+
npx mocha test/commands/db-manager.test.js --timeout 15000 --exit
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Stopping Docker Services
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
# Stop all services
|
|
189
|
+
docker compose down
|
|
190
|
+
|
|
191
|
+
# Stop and remove volumes (clean slate)
|
|
192
|
+
docker compose down -v
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Demo Environment Files
|
|
196
|
+
|
|
197
|
+
Located in `db-manager/demo/`:
|
|
198
|
+
|
|
199
|
+
| File | Database | Host | Port |
|
|
200
|
+
| ----------------- | -------------- | --------- | ----- |
|
|
201
|
+
| `sqlite3.env` | SQLite3 | — | — |
|
|
202
|
+
| `mysql.env` | MySQL 8.0 | localhost | 3306 |
|
|
203
|
+
| `postgres.env` | PostgreSQL 16 | localhost | 5432 |
|
|
204
|
+
| `mssql.env` | SQL Server | localhost | 1433 |
|
|
205
|
+
| `cockroachdb.env` | CockroachDB | localhost | 26257 |
|
|
206
|
+
| `oracle.env` | Oracle Free | localhost | 1521 |
|
|
207
|
+
| `mongodb.env` | MongoDB 7 | localhost | 27017 |
|
|
208
|
+
| `redis.env` | Redis 7 | localhost | 6379 |
|
|
209
|
+
| `dynamodb.env` | DynamoDB Local | localhost | 8000 |
|
|
210
|
+
|
|
211
|
+
## Seed Data
|
|
212
|
+
|
|
213
|
+
SQL seed files are in `db-manager/demo/seeds/`. Each creates two tables:
|
|
214
|
+
|
|
215
|
+
- **users** — id, name, email, created_at (5 sample rows)
|
|
216
|
+
- **products** — id, name, price, stock, created_at (5 sample rows)
|
|
217
|
+
|
|
218
|
+
## Troubleshooting
|
|
219
|
+
|
|
220
|
+
- **Port already in use**: Use `--port` to pick a different port
|
|
221
|
+
- **Connection refused**: Make sure the Docker container is running and healthy (`docker compose ps`)
|
|
222
|
+
- **Oracle slow to start**: Oracle can take 60–90 seconds to initialize. Wait for the healthcheck to pass
|
|
223
|
+
- **MSSQL tools path**: If the seed command fails, try `/opt/mssql-tools/bin/sqlcmd` instead of `/opt/mssql-tools18/bin/sqlcmd`
|