Database Migrations
Relevant source files
The following files were used as context for generating this wiki page:
Database migrations in the Quix project are managed using sequelize-cli to handle incremental and reversible changes to the PostgreSQL database schema. This system ensures that the database structure evolves in a controlled and versioned manner, which is crucial for maintaining data integrity across different development and production environments. Migrations are responsible for creating and altering tables that store core application data, such as Slack workspace configurations and credentials for various third-party integrations.
The setup process for a new developer or a new deployment explicitly includes running database migrations as a key step to initialize the database schema correctly. This is handled via a dedicated yarn script.
Sources: package.json:26-29, README.md:83-85
Tooling and Configuration
The project utilizes sequelize-cli for managing database schema migrations. The dependency and the scripts to run migrations are defined in the package.json file.
Sources: package.json:58, package.json:26-29
Migration Scripts
Several yarn scripts are available to interact with the migration system. These scripts are wrappers around sequelize-cli commands.
| Command | Description |
|---|---|
yarn db:migrate | Applies all pending migrations to the database. |
yarn db:migrate:undo | Reverts the most recent migration. |
yarn db:migrate:undo:all | Reverts all migrations that have been applied. |
Sources: package.json:26-29
Database Configuration
Database connection details are not hardcoded. The system is configured to read credentials from environment variables. The README.md file specifies the required variables for database setup.
DB_HOST: Database HostnameDB_PORT: Database PortDB_USER: Database UserDB_PASSWORD: Database PasswordDB_NAME: Database Name
Sources: README.md:46-51
Migration Workflow
The migration process is a standard part of the application setup and development workflow. When setting up the application for the first time or after pulling changes that include new migrations, a developer must run the migration command.
This diagram illustrates the database setup flow as part of the overall application installation.
Sources: README.md:32-88
Core Data Models
Migrations are responsible for creating the tables that back the application's core data models. These models, such as SlackWorkspace and various integration configurations (JiraConfig, GithubConfig, etc.), are central to Quix's functionality. The relationships between these models are defined by the migrations.
For example, a SlackWorkspace can have multiple associated integration configurations, allowing each Slack workspace to connect to different instances of services like JIRA, GitHub, and Notion.
Sources: src/slack/views/app_home.ts:13-26, src/lib/constants.ts:4-13
Entity Relationship Diagram
The following diagram shows the relationship between the central SlackWorkspace model and the various integration configuration models that are managed by database migrations. A single workspace can have one configuration for each supported integration.
This ER diagram is inferred from the code structure where SlackWorkspace holds relations to different config models.
Sources: src/slack/views/app_home.ts:13-26, 212-237, src/lib/constants.ts:15-144
Supported Integrations
The database schema includes tables for each supported integration, allowing Quix to store connection details and credentials securely. The list of supported integrations is defined as a constant and each has a corresponding configuration model.
- JIRA
- GitHub
- HubSpot
- PostgreSQL
- Salesforce
- Notion
- Okta
- Zendesk
- JumpCloud
- Linear
Sources: src/lib/constants.ts:4-13, 20-144, README.md:9-17
Summary
The database migration system, powered by sequelize-cli, is a fundamental component of the Quix application's architecture. It provides a robust, version-controlled mechanism for managing the PostgreSQL database schema. By codifying schema changes in migration files and providing simple yarn commands, the system ensures consistency across all environments and simplifies the development and deployment process. These migrations create and maintain the tables for essential data models, including workspace settings and all third-party integration configurations.