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

fix: db naming #1023

Merged
merged 4 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion loco-new/base_template/config/development.yaml.t
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ mailer:
# Database Configuration
database:
# Database connection URI
uri: {% raw %}{{{% endraw %} get_env(name="DATABASE_URL", default="{{settings.db.endpoint}}") {% raw %}}}{% endraw %}
uri: {% raw %}{{{% endraw %} get_env(name="DATABASE_URL", default="{{settings.db.endpoint | replace(from='NAME', to=settings.package_name) | replace(from='ENV', to='development')}}") {% raw %}}}{% endraw %}
# When enabled, the sql query will be logged.
enable_logging: false
# Set the timeout duration when acquiring a connection.
Expand Down
2 changes: 1 addition & 1 deletion loco-new/base_template/config/test.yaml.t
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ mailer:
# Database Configuration
database:
# Database connection URI
uri: {% raw %}{{{% endraw %} get_env(name="DATABASE_URL", default="{{settings.db.endpoint}}") {% raw %}}}{% endraw %}
uri: {% raw %}{{{% endraw %} get_env(name="DATABASE_URL", default="{{settings.db.endpoint | replace(from='NAME', to=settings.package_name) | replace(from='ENV', to='test')}}") {% raw %}}}{% endraw %}
# When enabled, the sql query will be logged.
enable_logging: false
# Set the timeout duration when acquiring a connection.
Expand Down
2 changes: 1 addition & 1 deletion loco-new/devnew.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
LOCO_DEV_MODE_PATH=../../ loco new
LOCO_DEV_MODE_PATH=../../ cargo run -- new
4 changes: 2 additions & 2 deletions loco-new/src/wizard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ impl DBOption {
#[must_use]
pub const fn endpoint_config(&self) -> &str {
match self {
Self::Sqlite => "sqlite://loco_app.sqlite?mode=rwc",
Self::Postgres => "postgres://loco:loco@localhost:5432/loco_app",
Self::Sqlite => "sqlite://NAME_ENV.sqlite?mode=rwc",
Self::Postgres => "postgres://loco:loco@localhost:5432/NAME_ENV",
Self::None => "",
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: loco-new/tests/templates/auth.rs
source: tests/templates/auth.rs
expression: "std::fs::read_to_string(generator.path(\"src/app.rs\")).expect(\"could not open file\")"
snapshot_kind: text
---
use async_trait::async_trait;
use loco_rs::{
Expand Down Expand Up @@ -51,5 +52,6 @@ impl Hooks for App {
Ok(())
}
fn register_tasks(_tasks: &mut Tasks) {
// tasks-inject (do not remove)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: loco-new/tests/templates/auth.rs
source: tests/templates/auth.rs
expression: "std::fs::read_to_string(generator.path(\"src/app.rs\")).expect(\"could not open file\")"
snapshot_kind: text
---
use async_trait::async_trait;
use loco_rs::{
Expand Down Expand Up @@ -51,5 +52,6 @@ impl Hooks for App {
Ok(())
}
fn register_tasks(_tasks: &mut Tasks) {
// tasks-inject (do not remove)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: loco-new/tests/templates/background.rs
source: tests/templates/background.rs
expression: "std::fs::read_to_string(generator.path(\"src/app.rs\")).expect(\"could not open file\")"
snapshot_kind: text
---
use async_trait::async_trait;
use loco_rs::{
Expand Down Expand Up @@ -54,5 +55,6 @@ impl Hooks for App {
Ok(())
}
fn register_tasks(_tasks: &mut Tasks) {
// tasks-inject (do not remove)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: loco-new/tests/templates/background.rs
source: tests/templates/background.rs
expression: "std::fs::read_to_string(generator.path(\"src/app.rs\")).expect(\"could not open file\")"
snapshot_kind: text
---
use async_trait::async_trait;
use loco_rs::{
Expand Down Expand Up @@ -54,5 +55,6 @@ impl Hooks for App {
Ok(())
}
fn register_tasks(_tasks: &mut Tasks) {
// tasks-inject (do not remove)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: loco-new/tests/templates/background.rs
source: tests/templates/background.rs
expression: "std::fs::read_to_string(generator.path(\"src/app.rs\")).expect(\"could not open file\")"
snapshot_kind: text
---
use async_trait::async_trait;
use loco_rs::{
Expand Down Expand Up @@ -51,5 +52,6 @@ impl Hooks for App {
Ok(())
}
fn register_tasks(_tasks: &mut Tasks) {
// tasks-inject (do not remove)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: loco-new/tests/templates/background.rs
source: tests/templates/background.rs
expression: "std::fs::read_to_string(generator.path(\"src/app.rs\")).expect(\"could not open file\")"
snapshot_kind: text
---
use async_trait::async_trait;
use loco_rs::{
Expand Down Expand Up @@ -54,5 +55,6 @@ impl Hooks for App {
Ok(())
}
fn register_tasks(_tasks: &mut Tasks) {
// tasks-inject (do not remove)
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
---
source: loco-new/tests/templates/db.rs
expression: "format!(\"{:#?}\",\n assertion::yaml::get_value_at_path(&content, &[\"database\"]).unwrap())"
source: tests/templates/db.rs
expression: "format!(\"{:#?}\",\nassertion::yaml::get_value_at_path(&content, &[\"database\"]).unwrap())"
snapshot_kind: text
---
Mapping {
"uri": Mapping {
Mapping {
"get_env(name=\"DATABASE_URL\"": Null,
"default=\"postgres://loco:loco@localhost:5432/loco_app\")": Null,
"default=\"postgres://loco:loco@localhost:5432/loco-app-test_development\")": Null,
}: Null,
},
"enable_logging": Bool(false),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
---
source: loco-new/tests/templates/db.rs
expression: "format!(\"{:#?}\",\n assertion::yaml::get_value_at_path(&content, &[\"database\"]).unwrap())"
source: tests/templates/db.rs
expression: "format!(\"{:#?}\",\nassertion::yaml::get_value_at_path(&content, &[\"database\"]).unwrap())"
snapshot_kind: text
---
Mapping {
"uri": Mapping {
Mapping {
"get_env(name=\"DATABASE_URL\"": Null,
"default=\"sqlite://loco_app.sqlite?mode=rwc\")": Null,
"default=\"sqlite://loco-app-test_development.sqlite?mode=rwc\")": Null,
}: Null,
},
"enable_logging": Bool(false),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
---
source: loco-new/tests/templates/db.rs
expression: "format!(\"{:#?}\",\n assertion::yaml::get_value_at_path(&content, &[\"database\"]).unwrap())"
source: tests/templates/db.rs
expression: "format!(\"{:#?}\",\nassertion::yaml::get_value_at_path(&content, &[\"database\"]).unwrap())"
snapshot_kind: text
---
Mapping {
"uri": Mapping {
Mapping {
"get_env(name=\"DATABASE_URL\"": Null,
"default=\"postgres://loco:loco@localhost:5432/loco_app\")": Null,
"default=\"postgres://loco:loco@localhost:5432/loco-app-test_test\")": Null,
}: Null,
},
"enable_logging": Bool(false),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
---
source: loco-new/tests/templates/db.rs
expression: "format!(\"{:#?}\",\n assertion::yaml::get_value_at_path(&content, &[\"database\"]).unwrap())"
source: tests/templates/db.rs
expression: "format!(\"{:#?}\",\nassertion::yaml::get_value_at_path(&content, &[\"database\"]).unwrap())"
snapshot_kind: text
---
Mapping {
"uri": Mapping {
Mapping {
"get_env(name=\"DATABASE_URL\"": Null,
"default=\"sqlite://loco_app.sqlite?mode=rwc\")": Null,
"default=\"sqlite://loco-app-test_test.sqlite?mode=rwc\")": Null,
}: Null,
},
"enable_logging": Bool(false),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: loco-new/tests/templates/db.rs
source: tests/templates/db.rs
expression: "std::fs::read_to_string(generator.path(\"src/app.rs\")).expect(\"could not open file\")"
snapshot_kind: text
---
use async_trait::async_trait;
use loco_rs::{
Expand Down Expand Up @@ -51,5 +52,6 @@ impl Hooks for App {
Ok(())
}
fn register_tasks(_tasks: &mut Tasks) {
// tasks-inject (do not remove)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: loco-new/tests/templates/db.rs
source: tests/templates/db.rs
expression: "std::fs::read_to_string(generator.path(\"src/app.rs\")).expect(\"could not open file\")"
snapshot_kind: text
---
use std::path::Path;
use async_trait::async_trait;
Expand Down Expand Up @@ -59,6 +60,7 @@ impl Hooks for App {
}
fn register_tasks(tasks: &mut Tasks) {
tasks.register(tasks::seed::SeedData);
// tasks-inject (do not remove)
}
async fn truncate(db: &DatabaseConnection) -> Result<()> {
truncate_table(db, users::Entity).await?;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: loco-new/tests/templates/db.rs
source: tests/templates/db.rs
expression: "std::fs::read_to_string(generator.path(\"src/app.rs\")).expect(\"could not open file\")"
snapshot_kind: text
---
use std::path::Path;
use async_trait::async_trait;
Expand Down Expand Up @@ -59,6 +60,7 @@ impl Hooks for App {
}
fn register_tasks(tasks: &mut Tasks) {
tasks.register(tasks::seed::SeedData);
// tasks-inject (do not remove)
}
async fn truncate(db: &DatabaseConnection) -> Result<()> {
truncate_table(db, users::Entity).await?;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: loco-new/tests/templates/initializers.rs
source: tests/templates/initializers.rs
expression: "std::fs::read_to_string(generator.path(\"src/app.rs\")).expect(\"could not open file\")"
snapshot_kind: text
---
use async_trait::async_trait;
use loco_rs::{
Expand Down Expand Up @@ -51,5 +52,6 @@ impl Hooks for App {
Ok(())
}
fn register_tasks(_tasks: &mut Tasks) {
// tasks-inject (do not remove)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
source: loco-new/tests/templates/initializers.rs
source: tests/templates/initializers.rs
expression: "std::fs::read_to_string(generator.path(\"src/app.rs\")).expect(\"could not open file\")"
snapshot_kind: text
---
use async_trait::async_trait;
use loco_rs::{
Expand Down Expand Up @@ -51,5 +52,6 @@ impl Hooks for App {
Ok(())
}
fn register_tasks(_tasks: &mut Tasks) {
// tasks-inject (do not remove)
}
}
Loading