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

Support Per-Engine Custom Templates #797

Open
theory opened this issue Oct 21, 2023 · 0 comments
Open

Support Per-Engine Custom Templates #797

theory opened this issue Oct 21, 2023 · 0 comments
Assignees
Labels

Comments

@theory
Copy link
Collaborator

theory commented Oct 21, 2023

#795 highlighted some issues with template resolution. The fix in #796 addresses the issue sufficiently for adding changes to multiple engines at once, but only if not using a custom template. The current design limits custom templates to a single engine -- a limitation dating from when add supported only one engine at a time (changed in way back in 0c7237c).

So do some re-thinking and re-organization of templates in order to better support both multiple engines and custom templates for multiple engines.

Here's what it looks like today:

etc/templates
├── deploy
│   ├── mysql.tmpl
│   ├── pg.tmpl
│   ├── sqlite.tmpl
├── revert
│   ├── mysql.tmpl
│   ├── pg.tmpl
│   ├── sqlite.tmpl
└── verify
    ├── mysql.tmpl
    ├── pg.tmpl
    └── sqlite.tmpl

Which is fine for a single template for each engine. Say we wanted to add a custom change, named create_table, with separate templates for the pg and sqlite engines. Currently it requires a structure like this:

etc/templates
├── deploy
│   ├── mysql.tmpl
│   ├── pg.tmpl
│   ├── sqlite.tmpl
├── revert
│   ├── mysql.tmpl
│   ├── pg.tmpl
│   ├── sqlite.tmpl
└── verify
    ├── mysql.tmpl
    ├── pg.tmpl
    └── sqlite.tmpl

But what engine does it apply to? In order to support the same template for multiple engines, add support for engine-specific subdirectories, so we can do this, instead:

etc/templates
├── deploy
│   ├── mysql.tmpl
│   ├── pg
│   │   └── create_table.tmpl
│   ├── pg.tmpl
│   ├── sqlite
│   │   └── create_table.tmpl
│   └── sqlite.tmpl
├── revert
│   ├── mysql.tmpl
│   ├── pg
│   │   └── create_table.tmpl
│   ├── pg.tmpl
│   ├── sqlite
│   │   └── create_table.tmpl
│   └── sqlite.tmpl
└── verify
    ├── mysql.tmpl
    ├── pg
    │   └── create_table.tmpl
    ├── pg.tmpl
    ├── sqlite
    │   └── create_table.tmpl
    └── sqlite.tmpl

The defaults for each engine remain as they are, as do custom templates that can be the same across engines (or are only ever used for one). But adding this level allows for more customization.

@theory theory self-assigned this Oct 21, 2023
@theory theory added the feature label Oct 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant