gray-carpenter-62658
04/30/2023, 5:46 PMSecrets.toml
and Secrets.dev.toml
which I did use to change which sql schema file I use (the dev one clears the tables, other than that they are the same). I'm not sure if I should do something special to read in the contents of the file:
rs
let schema = secret_store
.get("SCHEMA")
.expect("SCHEMA secret not found.");
let schema = read_to_string(schema).expect("SCHEMA is read correctly.");
I feel like this should be fine (again, works fine locally and none of the expect error messages are appearing in the logs so idk) but including it anyway.
I dont really have any other ideas as to what might be causing this. Im using Axum. In case this matters, my dashboard
page appears to be empty stillenough-oil-62271
04/30/2023, 5:54 PMSecrets.toml
.
You may want to look into the static folder functionality (https://docs.shuttle.rs/resources/shuttle-static-folder) that Shuttle does know about for this kind of use case?
Alternatively I'd suggest perhaps using compiler attributes like #[cfg(debug_assertions)]
(memory's hazy on the exact syntax, but that's close I think?) to swap out the ones you want based on whether it's compiled locally in debug mode, or in release mode.enough-oil-62271
04/30/2023, 5:54 PMCREATE TABLE IF NOT EXISTS ...
gray-carpenter-62658
04/30/2023, 5:59 PMenough-oil-62271
04/30/2023, 5:59 PMgray-carpenter-62658
04/30/2023, 6:00 PMenough-oil-62271
04/30/2023, 6:01 PMenough-oil-62271
04/30/2023, 6:01 PMenough-oil-62271
04/30/2023, 6:01 PMgray-carpenter-62658
04/30/2023, 6:02 PMgray-carpenter-62658
04/30/2023, 6:11 PMsql
folder and put the files in there
rs
#[shuttle_runtime::main]
async fn axum(
#[shuttle_shared_db::Postgres] pool: PgPool,
#[shuttle_secrets::Secrets] secret_store: SecretStore,
#[shuttle_static_folder::StaticFolder(folder = "sql")] static_folder: PathBuf,
) -> shuttle_axum::ShuttleAxum {
let schema = secret_store
.get("SCHEMA")
.expect("SCHEMA secret not found.");
let schema =
read_to_string(static_folder.as_path().join(schema)).expect("SCHEMA is read correctly.");
// ...
}
I feel like this should preserve the files, maybe something else is wrong? (this again works locally)enough-oil-62271
04/30/2023, 6:19 PMcargo shuttle logs <id>
with the last deployment id?gray-carpenter-62658
04/30/2023, 6:23 PMgray-carpenter-62658
04/30/2023, 6:23 PMgray-carpenter-62658
04/30/2023, 6:27 PMgray-carpenter-62658
04/30/2023, 6:27 PMenough-oil-62271
04/30/2023, 6:29 PMenough-oil-62271
04/30/2023, 6:29 PMgray-carpenter-62658
04/30/2023, 6:30 PMsql
-- schema.dev.sql
DROP TABLE IF EXISTS metadata;
DROP TABLE IF EXISTS urls;
CREATE TABLE urls (
id VARCHAR(6) PRIMARY KEY,
url VARCHAR NOT NULL
);
CREATE TABLE metadata (
id VARCHAR(6) REFERENCES urls(id),
url VARCHAR NOT NULL,
hits INT NOT NULL
);
-- schema.sql
CREATE TABLE urls (
id VARCHAR(6) PRIMARY KEY,
url VARCHAR NOT NULL
);
CREATE TABLE metadata (
id VARCHAR(6) REFERENCES urls(id),
url VARCHAR NOT NULL,
hits INT NOT NULL
);
gray-carpenter-62658
04/30/2023, 6:30 PMenough-oil-62271
04/30/2023, 6:31 PMgray-carpenter-62658
04/30/2023, 6:31 PMenough-oil-62271
04/30/2023, 6:32 PMpanic
is not getting caught by the logging infra, thengray-carpenter-62658
04/30/2023, 6:32 PMgray-carpenter-62658
04/30/2023, 6:32 PMgray-carpenter-62658
04/30/2023, 6:34 PMenough-oil-62271
04/30/2023, 6:35 PMShuttleAxum
a result type? it is for the serenity wrapper at least, so I do stuff like... https://github.com/vexx32/thread-tracker/blob/main/src/main.rs#L274C11-L279enough-oil-62271
04/30/2023, 6:36 PMenough-oil-62271
04/30/2023, 6:36 PMgray-carpenter-62658
04/30/2023, 6:36 PMgray-carpenter-62658
04/30/2023, 6:40 PMenough-oil-62271
04/30/2023, 6:40 PMgray-carpenter-62658
04/30/2023, 6:45 PMenough-oil-62271
04/30/2023, 6:45 PMgray-carpenter-62658
04/30/2023, 6:46 PMenough-oil-62271
04/30/2023, 6:51 PMcargo shuttle deploy
it'll give you a connection string for the DB that looks like this:
postgres://user-PROJECT-NAME:DB-PASSWORD@db.shuttle.rs:5432/db-PROJECT-NAME
take the user-PROJECT-NAME
as the username, the DB-PASSWORD
as the password, and give it to pgAdmin like this:
https://cdn.discordapp.com/attachments/1102289940835995748/1102306254405246976/image.pngâ–¾
enough-oil-62271
04/30/2023, 6:51 PMenough-oil-62271
04/30/2023, 6:52 PMdeploy
or if you do a project restart
, I forget which. probably every deploy?enough-oil-62271
04/30/2023, 6:52 PMcargo shuttle resource list
for the most recent connection string + passwordenough-oil-62271
04/30/2023, 6:53 PMdb-PROJECT-NAME
just like in the connection stringenough-oil-62271
04/30/2023, 6:54 PMgray-carpenter-62658
04/30/2023, 7:15 PMenough-oil-62271
04/30/2023, 7:15 PM