Exodus — Deno’s first MongoDB compatible data migration tool
As Deno continues to make way toward becoming production ready, the adolescent runtime environment is still in need of many tools for which to make developer’s lives easier. While the engineers over at The Deno Company are surely working diligently to improve their RTE’s built in functionalities, the majority of a typical Deno developer’s needs are still only to be solved by third-party modules. Unfortunately for those interested in performing any form of data manipulation, Deno’s third-party modules are lacking in data manipulation helper tools, especially NoSql database related tools. Luckily enough for said developers, a team of involved engineers has just announced Exodus, a brand-new third-party module to solve the needs of all who would like to perform data migrations within the Deno runtime.
What is Exodus?
Exodus is the first ever MongoDB compatible data migration tool developed for the Deno runtime environment. Team Exodus made it a priority to show their support for the Deno community via employing a variety of other third-party module’s within the command-line tool. Utilizing the popular third-party module, deno-mongo acts as a driver in order to connect with a MongoDB database as there is currently no official supported MongoDB driver for Deno. Following this connection, Exodus then makes use of yet another popular Deno module, Cliffy, in order to construct a user friendly command-line tool which allows for users to deploy intuitive version-controlled MongoDB database schema migrations as well as full MongoDB database migrations.
Why use Exodus?
While MongoDB may be a non-relational/native schema-free database program, in most use cases many developers are prone to use it with the popular ODM Mongoose, which presents the ability to create schemas to shape the data within the documents of which we insert into our collections. As an application’s data needs evolve, we may need to alter, add, or simply repair existing data within our documents. Without an incremental and reversible way to apply these migrations, one would have to manually make tedious adaptations to their data. Performing this method of manual schema migration would more than likely cause for a multitude of unforeseen errors and over all difficulties in tracking changes made to the database. Exodus provides relief to such an issue via offering an automated way to perform incremental and reversible migrations in a version controlled manner in order to keep log of changes made to the database. In addition to schema migrations, Exodus also grants the ability to extract and transfer all data within a MongoDB database.
How to use Exodus?
For Schema Migration Projects
To use Exodus for version-controlled schema migrations, the user begins by running the init command to initialize a migration project. This command will then generate a migrations directory as well as a database configuration file where the user is prompted to fill in the designated lines in order to connect one’s MongoDB database.
Once the user’s database is properly configured, run the create command along with a user designated name for the migration project. This command will populate the migrations directory with a file with the name being: date and time + [user’s migration title] appended to it. Each file generated via the create command is occupied by two functions: fwd and back. This is where the user can define the actions of the data migration and the steps to rollback the changes. The two arguments passed in to each function (client,db) allow the user to perform commands and actions just as one would in a normal Mongo shell.
The user may choose to apply migrations incrementally or all at once using the fwd or full commands respectively. For every successful migration a log document will be created and stored in a 'migrationLog' collection within the connected database. Rolling-back changes is done incrementally. Successful rollbacks will delete the associated log file from the migrationLog collection within the user’s database.
For Full Database Migration Projects
To use Exodus for full database migrations, the user begins by running the dbInit command to initialize a database migration project. This command will then generate a database-migration directory as well as a pair of database configuration files, one of which is for setting up the connection to the database the user would like to extract the data from and the other configuration file is to connect the database of which the extracted data is to be applied.
Once both of the databases are properly configured, the user can then run the extract command. This command extracts the data of the existing MongoDB database and creates a directory with a corresponding name to the extracted database. Within said directory, a data folder is generated and populated by files containing the data of each collection in the extracted database. Ensuing the extraction, the user may run the apply command which migrates the extracted data to the database specified in the second database configuration file.
Meet the Team
Exodus is a beta product developed in partnership with OSLabs.