Package Exports
- appwrite-utils-cli
- appwrite-utils-cli/src/main.ts
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (appwrite-utils-cli) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
appwrite-utils-cli
Overview
appwrite-utils-cli is a powerful command-line interface tool designed for Appwrite developers who need to manage database migrations, schema generation, data import, and much more. This CLI tool facilitates complex tasks like setting up databases, running migrations, generating schemas, and managing backups efficiently, making it an indispensable part of your Appwrite project management.
Features
- Interactive Mode: Run the CLI in interactive mode for a guided experience through all available options.
- Easy Configuration: Initialize your Appwrite project configurations interactively directly from the command line.
- Database Migrations: Control the migration process with options to target specific databases and collections.
- Schema Generation: Generate and manage TypeScript schemas directly from your Appwrite database schemas.
- Data Import: Facilitate the import of data into your Appwrite databases with comprehensive command-line support.
- Backup Management: Create backups of your Appwrite databases to ensure data integrity and safety.
- Flexible Database Management: Includes commands to wipe databases, documents, or user data, providing flexibility in managing your database state during development or testing.
- Data Transfer: Transfer data between databases, collections, and even between local and remote Appwrite instances.
- Configuration Synchronization: Sync your local Appwrite configuration with your remote Appwrite project.
Installation
To use appwrite-utils-cli, you can install it globally via npm to make it accessible from anywhere in your command line:
npm install -g appwrite-utils-cliHowever, due to the rapid development of this project, it's recommended to use the following command:
npx --package=appwrite-utils-cli@latest appwrite-migrate [options]Note: Do not install this locally into your project. It is meant to be used as a command-line tool only.
Usage
After installation, you can access the tool directly from your command line using the provided commands.
Interactive Mode
Run the CLI in interactive mode:
npx --package=appwrite-utils-cli@latest appwrite-migrate --itThis will guide you through all available options interactively.
Non-Interactive Mode
You can also use specific flags to run tasks without the interactive prompt:
npx --package=appwrite-utils-cli@latest appwrite-migrate [options]Available options:
--it: Run in interactive mode--dbIds: Comma-separated list of database IDs to operate on--collectionIds: Comma-separated list of collection IDs to operate on--bucketIds: Comma-separated list of bucket IDs to operate on--wipe: Wipe data (all: everything, docs: only documents, users: only user data)--generate: Generate TypeScript schemas from database schemas--import: Import data into your databases--backup: Perform a backup of your databases--writeData: Write converted imported data to file--push: Push your local Appwrite config to your configured Appwrite Project--sync: Synchronize by pulling your Appwrite config from your configured Appwrite Project--endpoint: Set the Appwrite endpoint--projectId: Set the Appwrite project ID--apiKey: Set the Appwrite API key--transfer: Transfer data between databases or collections--fromDbId: Set the source database ID for transfer--toDbId: Set the destination database ID for transfer--fromCollectionId: Set the source collection ID for transfer--toCollectionId: Set the destination collection ID for transfer--fromBucketId: Set the source bucket ID for transfer--toBucketId: Set the destination bucket ID for transfer--remoteEndpoint: Set the remote Appwrite endpoint for transfers--remoteProjectId: Set the remote Appwrite project ID for transfers--remoteApiKey: Set the remote Appwrite API key for transfers
Examples
Transfer Databases
Transfer databases within the same project or from a local to a remote project:
npx appwrite-utils-cli appwrite-migrate --transfer --fromDbId sourceDbId --toDbId targetDbId --remoteEndpoint https://appwrite.otherserver.com --remoteProjectId yourProjectId --remoteApiKey yourApiKeyTransfer Specific Collections
Transfer specific collections from one place to another, with all of their data:
npx appwrite-utils-cli appwrite-migrate --transfer --fromDbId sourceDbId --toDbId targetDbId --fromCollectionId sourceCollectionId --toCollectionId targetCollectionId --remoteEndpoint https://appwrite.otherserver.com --remoteProjectId yourProjectId --remoteApiKey yourApiKeyTransfer Buckets
Transfer files between buckets:
npx appwrite-utils-cli appwrite-migrate --transfer --fromBucketId sourceBucketId --toBucketId targetBucketId --remoteEndpoint https://appwrite.otherserver.com --remoteProjectId yourProjectId --remoteApiKey yourApiKeyAdditional Notes
If you run out of RAM during large data imports, you can increase Node's memory allocation:
export NODE_OPTIONS="--max-old-space-size=16384"
This sets the allocation to 16GB. For most cases, 8GB (
8192) should be sufficient.The CLI now supports OpenAPI generation for each attribute in the schema. Add a
descriptionto any attribute or collection, and it will export that schema to theappwrite/openapifolder.
This updated CLI ensures that developers have robust tools at their fingertips to manage complex Appwrite projects effectively from the command line, with both interactive and non-interactive modes available for flexibility.