Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add createTables Config Option to Disable Automatic DDL Operations #377

Merged
merged 2 commits into from
Sep 28, 2024

Conversation

TheCodedOne
Copy link
Contributor

Summary:

This PR introduces a new configuration option called createTables to the database adapters. This option allows users to toggle whether the database adapters should attempt to run their table creation (DDL) schema files.

Context & Motivation:

In certain production environments, database servers are configured to disable Data Definition Language (DDL) modifications, such as table creation, to maintain stability and security. In such cases, automatically running the table creation schema may result in errors or unintended behavior.

To address this, the createTables option provides more flexibility by allowing users to control whether schema creation is attempted during database initialization.

Changes:

  • New Config Option:

    • Added createTables to the configuration file.
    • Type: Boolean
    • Default: true (maintains current behavior).
    • When set to false, the database adapters will skip running their schema creation scripts, preventing any DDL operations.
  • Database Adapter Updates:

    • Modified the logic in each relevant database adapter to check the createTables flag before executing any schema creation scripts.

Usage:

  • To disable table creation in a production environment:
     ... other configs ...
    
    # Whether to run the creation SQL on the database when the server starts. Don't modify this unless you know what you're doing!
    create_tables: false
    
     ... other configs ...
    This ensures that the application will not attempt to modify the database schema, preventing any conflicts with database policies that disable DDL operations.

Testing:

  • Manual tests were performed on environments where DDL operations are disabled to confirm the configuration works as expected.

Impact:

  • Backward Compatibility: The default value of createTables is set to true, ensuring that existing functionality remains unchanged for users who do not modify their configuration.
  • Production Safety: Provides a safe and configurable way to disable DDL operations in production environments, reducing the risk of errors caused by unauthorized schema modifications.
  • Potential Issues: If createTables is set to false and the required database schema is not already in place, this can lead to runtime errors or missing tables. This setting should only be used by users who are certain that the schema has already been applied to the database. It is recommended for advanced users familiar with their database environment and schema management processes.

Copy link
Owner

@WiIIiam278 WiIIiam278 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the detailed PR description and for contributing this change. :)

@WiIIiam278 WiIIiam278 merged commit 842ec0e into WiIIiam278:master Sep 28, 2024
1 check passed
WiIIiam278 pushed a commit that referenced this pull request Sep 29, 2024
…ions (#377)

* Add config option for creating tables

* Move createTables config to a better position

(cherry picked from commit 842ec0e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants