Examples
This directory contains examples demonstrating how to use the go-arangodb-migrator library.
Basic Example
The basic/
directory contains a simple example that:
- Connects to an ArangoDB instance
- Creates or uses an existing database
- Runs migrations from JSON files
Running the Basic Example
- Make sure you have ArangoDB running locally on the default port (8529)
- Navigate to the basic example directory:
cd examples/basic
- Run the example:
go run main.go
Example Migration
The basic example includes sample migration files that create a library management system:
000001_initial_schema.json
- Creates books and authors collections with indexes and a graph
000002_add_locations_and_categories.json
- Adds libraries with geo indexes and categories
000003_add_sample_data.json
- Adds sample books, authors, and relationships
The example demonstrates:
- Document and edge collections
- Persistent and geo indexes
- Named graphs with multiple edge definitions
- Complex relationships between entities
Environment Variables Example
The environment-variables/
directory contains an example that demonstrates how to use environment variables with the CLI tool. This is especially useful for:
- Containerized environments (Docker, Kubernetes)
- CI/CD pipelines
- Production deployments
- Avoiding sensitive data in command-line arguments
Running the Environment Variables Example
-
Set up your environment variables:
export DATABASE=example_db
export ARANGO_PASSWORD=your_password
export ARANGO_ADDRESS=http://localhost:8529
-
Run the example:
cd examples/environment-variables
go run main.go
See examples/environment-variables/README.md
for detailed documentation.
Customizing Examples
To use these examples with your own ArangoDB instance:
- Update the connection details in
main.go
- Modify the database name
- Create your own migration files in the
migrations/
directory
- Run the example
See the main README.md for detailed documentation on the migration file format and supported operations.