Updates
This commit is contained in:
@@ -20,6 +20,8 @@ A schema-driven MariaDB manager for [Bun](https://bun.sh), featuring automatic s
|
||||
- [`typedef`](#typedef--generate-typescript-types-only)
|
||||
- [`backup`](#backup--sql-dump-backup)
|
||||
- [`restore`](#restore--restore-from-an-sql-dump)
|
||||
- [`export`](#export--portable-sql--schema-archive)
|
||||
- [`import`](#import--sql-or-full-export-archive)
|
||||
- [`admin`](#admin--interactive-admin-tools)
|
||||
- [CRUD API](#crud-api)
|
||||
- [Select](#select)
|
||||
@@ -191,6 +193,7 @@ The config file must be named `bun-mariadb.config.ts` and placed at the project
|
||||
| `db_dir` | `string` | Yes | Directory for schema, types, and local artifacts (relative to project root) |
|
||||
| `db_backup_dir` | `string` | No | Backup directory name, relative to `db_dir` (default: `.backups`) |
|
||||
| `max_backups` | `number` | No | Max backup files to keep (default: `10`) |
|
||||
| `max_exports` | `number` | No | Max export archives to keep (default: `10`) |
|
||||
| `typedef_file_path` | `string` | No | Output path for generated TypeScript types (relative to project root) |
|
||||
| `db_config` | `object` | No | Extra options passed to Bun's `SQL` MariaDB adapter |
|
||||
| `charset` | `string` | No | Database charset (default: `utf8mb4`) |
|
||||
@@ -359,6 +362,75 @@ Interactive picker of available `.sql` backups (newest first). Imports the selec
|
||||
|
||||
Requires `mariadb` or `mysql` on `PATH`.
|
||||
|
||||
### `export` — Portable SQL + schema archive
|
||||
|
||||
```bash
|
||||
bunx bun-mariadb export [options]
|
||||
```
|
||||
|
||||
| Option | Description |
|
||||
| ------------------- | --------------------------------------------------------------------------- |
|
||||
| `-o`, `--output` | Output archive path (`.tar.gz` or `.zip`). Defaults to `{db_dir}/.exports` |
|
||||
| `-f`, `--format` | When `--output` is omitted: `tar.gz` (default) or `zip` |
|
||||
|
||||
Creates a portable archive containing:
|
||||
|
||||
1. `dump.sql` — full SQL dump (same options as `backup`)
|
||||
2. `schema.ts` — the project’s TypeScript schema file from `db_dir`
|
||||
|
||||
Archives are written to `{db_dir}/.exports` (sibling of the backups directory). Old exports are pruned using `max_exports`.
|
||||
|
||||
**Examples:**
|
||||
|
||||
```bash
|
||||
# Write {db_name}-{timestamp}.tar.gz into {db_dir}/.exports
|
||||
bunx bun-mariadb export
|
||||
|
||||
# Explicit path / format
|
||||
bunx bun-mariadb export -o ./my-app-export.tar.gz
|
||||
bunx bun-mariadb export -f zip
|
||||
bunx bun-mariadb export -o ./my-app-export.zip
|
||||
```
|
||||
|
||||
Requires `mariadb-dump` or `mysqldump` on `PATH`. Zip output also requires `zip`.
|
||||
|
||||
### `import` — SQL or full export archive
|
||||
|
||||
```bash
|
||||
bunx bun-mariadb import [file] [options]
|
||||
```
|
||||
|
||||
| Option | Description |
|
||||
| ---------------- | --------------------------------------------------------------------------- |
|
||||
| `[file]` | Path to a `.sql` dump or export archive (`.tar.gz` / `.tar` / `.zip`) |
|
||||
| `--sql-only` | Archive only: restore SQL, do not overwrite `schema.ts` |
|
||||
| `--schema-only` | Archive only: write `schema.ts`, do not restore SQL |
|
||||
|
||||
Behavior:
|
||||
|
||||
- **`.sql` file** — restores SQL into the configured database (same as restore, but non-interactive)
|
||||
- **Export archive** — restores `dump.sql` and writes `schema.ts` into `db_dir`
|
||||
- **No file argument** — interactive picker of archives in `{db_dir}/.exports`
|
||||
|
||||
**Examples:**
|
||||
|
||||
```bash
|
||||
# Plain SQL dump
|
||||
bunx bun-mariadb import ./db/.backups/my_app-1710000000000.sql
|
||||
|
||||
# Full export (SQL + schema.ts)
|
||||
bunx bun-mariadb import ./db/exports/my_app-1710000000000.tar.gz
|
||||
|
||||
# Archive: SQL only / schema only
|
||||
bunx bun-mariadb import ./export.tar.gz --sql-only
|
||||
bunx bun-mariadb import ./export.tar.gz --schema-only
|
||||
|
||||
# Interactive picker (from {db_dir}/.exports)
|
||||
bunx bun-mariadb import
|
||||
```
|
||||
|
||||
Requires `mariadb` or `mysql` on `PATH`. Zip archives also require `unzip`.
|
||||
|
||||
### `admin` — Interactive admin tools
|
||||
|
||||
```bash
|
||||
|
||||
Reference in New Issue
Block a user