#database-migrations #couch-db #database-schema #orm #migration #json #creation

bin+lib couchdb-orm

couchdb-orm Copyright (C) 2020-2023 OpenToolAdd This program comes with ABSOLUTELY NO WARRANTY; This is free software, and you are welcome to redistribute it under certain conditions; type `show-license’ for details. A CLI ORM to manage some Databases operations like migration, schema creation, etc…. For the moment it only handle CouchDB.

7 releases

0.1.6 Sep 25, 2022
0.1.5 Aug 28, 2022
0.1.4 Feb 11, 2021
0.1.3 Jan 16, 2021
0.1.2 Dec 28, 2020

#1460 in Database interfaces

29 downloads per month

Custom license

285KB
5.5K SLoC

Rust 4K SLoC // 0.2% comments Shell 1K SLoC // 0.3% comments Pan 685 SLoC INI 42 SLoC // 0.6% comments

CouchDB ORM

A CouchDB ORM built in Rust with Actix runtime and web client.

@TODO

  • Network
    • Add chunking to request to not overflow memory
  • seeding
    • Add Seeding capacity from JSON ?
    • Add Seeding capacity from rust models
  • Finish migrate_db tasks in clients/couchdb/actions/db/migrate
    • actually execute the migration
    • Pagination and limits (if big database, dont store everyting in memory, it will break)
    • Check schema entry with database schema
  • clean database
  • Security
    • Management via model
  • Backup
    • JSON associated to a seed
  • Restore
    • Link backups to seeding file
  • View
    • Views via models
    • Design Docs via models
  • Test creation of files and folder structure
    • utils
    • register schema
    • migrations
    • seeding
    • backups
    • restore
  • tests clients actions
  • Better separation between lib and bin of couchdb-orm
  • Integration use case testing

Commands

Every Database action executed on a couchdb instance needs some authentication.
The CLI will search for a .env file at the root of the execution folder.
If not present it will rely on env variables.
If there are no variables, it will crash before executing anything.
Copy the .env.tpl file at the root to have a working base and configure your instance of couchdb if it is not the default coming with this project.

couchdb-orm db

Launch actions on a specific database. see --help for available actions

couchdb-orm db create <db-names>

Create X databases based on name (comma separated)

couchdb-orm db delete <db-names>

Delete X databases based on name (comma separated)

couchdb-orm db migrate

Performs a migration on a given table. Some migrations must be registered. Interaction: Space to select, Enter to validate

couchdb-orm register

Register something in the system. see --help for available actions

couchdb-orm register schema <path> <db-name>

Register a schema and version's it. <path> is the path to the file containing the model and all it's dependencies. <db-name> is the database for which the schema should be registered.

couchdb-orm register migration <db-name>

Register a migration based on 2 available schemas. <db-name> is the database for which the migration should be registered. Interaction: Space to select, Enter to validate

Dev

Dependencies

  • Rust >= 1.50
    • For the moment, needs Rust Nightly to be built for features:
      • #![feature(proc_macro_span)
  • Docker: For couchdb service for tests
  • Docker-Compose: For couchdb service for tests

Make Commands

make build-base-image

Will build the base couchdb-docker image needed for the project. Useful for testing and dev

make start-couchdb

Launch the couchdb instance with the docker-compose.yml

make test

Launch the tests with cargo. For the moment its a single thread because it is needed to clean the test folder everytime to test filesystem interaction.

make coverage

Uses Tarpaulin to make HTML coverage in the coverage directory

make install

Install the package as a CLI tool to use with couchdb-orm in command-line

Tests

Docs

License

Copyright (C) 2020-2023  OpenToolAdd

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
contact: contact@tool-add.com

Dependencies

~24–36MB
~629K SLoC