Directus Auto Migrate

screenshot of Directus Auto Migrate

A CLI to automatically generate Directus migrations based on the changes in a real instance

Overview

This package is no longer maintained due to native schema migrations introduced in Directus. The package solves the problem of running migrations in Directus to support automation between environments. It allows users to create migrations using the Directus UI instead of writing manual queries, which can be time-consuming and error-prone. The package generates a state file that contains the schema and data from the system tables. Users can make changes in the Directus UI, run the script again to create a migration, and commit the state file to their source code management system. Optional arguments allow customization of the environment file, state file, migrations directory, and format (JavaScript or TypeScript).

Features

  • Automatic generation of a state file containing schema and data from the system tables
  • Comparison between saved state and current database state to create a migration
  • Support for customization through optional arguments like environment file, state file, migrations directory, and format
  • Great level of compatibility with Directus by using the same environment variables

Summary

This package provides a solution for running schema migrations in Directus to support automation between environments. It eliminates the need for manual query writing and leverages the Directus UI to make the migration process easier. By generating a state file and comparing it to the current database state, users can create migrations for their Directus app. Customization options are available through optional arguments. It is important to note that the package is experimental and has only been tested with Postgres. Users are advised to inspect the generated queries and reset their database after migration to ensure expected functionality. Docker is recommended for easier database management and to leverage the Directus migrations system.

eslint
Eslint

ESLint is a linter for JavaScript that analyzes code to detect and report on potential problems and errors, as well as enforce consistent code style and best practices, helping developers to write cleaner, more maintainable code.

typescript
Typescript

TypeScript is a superset of JavaScript, providing optional static typing, classes, interfaces, and other features that help developers write more maintainable and scalable code. TypeScript's static typing system can catch errors at compile-time, making it easier to build and maintain large applications.