https://linen.dev logo
Custom error: failed to provision shuttle_shared_d...
# help
c
I'm running Shuttle 0.12.0. I was able to get a DB setup with the simple
todos
table, however when I tried adding in another table (
users
) and then tried running
cargo shuttle deploy
then I got this error. My main.rs:
Copy code
rust
#[shuttle_runtime::main]
async fn rocket(
    #[shuttle_shared_db::Postgres(
        local_uri = "postgres://postgres:{secrets.DB_PASS}@localhost:5432/yousearch"
    )]
    pool: PgPool,
    #[shuttle_secrets::Secrets] secret_store: SecretStore,
) -> shuttle_rocket::ShuttleRocket { 
  pool.execute(include_str!("../schema.sql"))
        .await
        .map_err(CustomError::new)?;
}
My schema is pretty simple:
Copy code
sql
DROP TABLE IF EXISTS todos;

CREATE TABLE todos (id serial PRIMARY KEY, note TEXT NOT NULL);

DROP TABLE IF EXISTS users;

CREATE TABLE users (
  id SERIAL PRIMARY KEY,
  first_name TEXT,
  last_name TEXT,
  email TEXT,
  password TEXT,
  user_type TEXT
);
Anyone know what could be happening right now? My repo is here: https://github.com/GabeMeister/yousearch-api I'm running Ubuntu 22.04.2 LTS.
Here's my log file from running
cargo shuttle logs <deployment_id>
a
Did you deploy this project before? If so you need to delete your
_sqlx_migrations
table - otherwise it will try to reapply the same file and fail as the file already exists
Once I get on the pc I can have a quick look for you
c
Ohh, I see now. I just had my
schema.sql
file that initialized the database, and then I went to create a new
users
table, didn't realize I needed a sqlx migration
Is the general convention that to initialize a database, you have a schema.sql file, and then for any changes you want to make you have a sqlx migration script?
a
Yeah basically. The idea is that if you want to make a migration change to an already existing db you need to add a new SQL file
You can also of course just drop the SQLx migrations table itself as I said before but that's not really a good idea if you're trying to do something in prod that actually serves customers
4 Views