Skip to content

Split queries.sql into smaller, domain-specific files #2735

@13unk0wn

Description

@13unk0wn

Is your feature request related to a problem? Please describe.
The queries.sql file is becoming very large and contains SQL queries for many different domains (subscribers, campaigns, lists, etc.). This makes it difficult to navigate, maintain, and debug queries. The current approach of loading the entire file into memory at once can also be inefficient.

Describe the solution you'd like
I propose to split the queries.sql file into smaller, domain-specific files within a new queries/ directory. For example:

  • queries/subscribers.sql
  • queries/campaigns.sql
  • queries/lists.sql
  • ... and so on.

This change would involve the following steps:

  1. File Splitting: Create the new SQL files and move the corresponding queries from queries.sql to these new files.
  2. Code Changes:
    • In cmd/init.go, cmd/install.go and cmd/main.go, modify the query loading logic to iterate over all files in the queries/ directory.
    • For each file, use the existing readQueries function to parse the queries.
    • Merge the resulting query maps into a single map that the application can use.
  3. Build Process:
    • Update the Makefile to include the new queries/ directory in the build dependencies.
    • Update the initFS function in cmd/init.go to embed the new queries/ directory into the application binary.

This refactoring will improve code organization, making it easier for developers to work with the SQL queries and improving the overall maintainability of the project. This could also be a good "good first issue" for new contributors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions