-
-
Notifications
You must be signed in to change notification settings - Fork 319
feat: ability to configure foreign_keys pragma for SQLite #1346
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @ryands17, for your pull request.
Instead of configuring each PRAGMA
setting individually, perhaps we could introduce a more general mechanism. For instance, changing the enable_foreign_keys
setting to run_on_start
would allow users to configure any PRAGMA settings they desire. This approach would offer greater flexibility and accommodate a wider range of configurations.
WDYT?
@kaplanelad I think that's a better approach! Would this be through the config itself? So instead of maybe a single value, we could add the options specified currently |
If we add this setup for each property, it will be irrelevant for Postgres. I think a generic configuration would be a better approach. |
@kaplanelad Is there a DB specific config that can be added? I can look into that and add these configurable setting there with defaults if not passed in. |
You can retain the existing configuration; however, if a new configuration is provided, it will override the existing one. Configuration Example ...
# Database Configuration
database:
# Database connection URI
uri: {{ get_env(name="DATABASE_URL", default="sqlite://myapp_development.sqlite?mode=rwc") }}
# Commands to run when the database starts
run_on_start:
PRAGMA foreign_keys = ON;
PRAGMA journal_mode = WAL;
PRAGMA synchronous = NORMAL;
PRAGMA mmap_size = 134217728;
PRAGMA journal_size_limit = 67108864;
PRAGMA cache_size = 2000;
... Behavior
WDYT? |
@kaplanelad Makes sense! I'm guessing this would just be for SQLite so I can update this PR to contain this if that's ok? |
Yes, sounds good! |
4042fa3
to
a8c6995
Compare
@kaplanelad made the changes, wdyt? |
src/config.rs
Outdated
@@ -218,6 +218,25 @@ pub struct Database { | |||
/// various things in development. | |||
#[serde(default)] | |||
pub dangerously_recreate: bool, | |||
|
|||
// sqlite run on start commands |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, this value should be supported for other cases as well.
So maybe add a comment explaining what it does?
For example: Execute query after initializing the DB
Can you check my note? |
b19f1f2
to
6ebc685
Compare
@kaplanelad Does this look good? |
36c5457
to
121713b
Compare
This PR allows configuring the
foreign_keys
pragma for SQLite. Some projects work without foreign keys so this would be a nice addition to the configuration