mirror of https://github.com/zer0bin-dev/zer0bin
🐛 fix: Fix migrator
This commit is contained in:
parent
794403ae97
commit
36e81a6c4f
|
@ -1 +1 @@
|
||||||
alter table pastes add column single_view boolean default false;
|
ALTER TABLE pastes ADD column single_view BOOLEAN DEFAULT false;
|
||||||
|
|
|
@ -24,7 +24,7 @@ pub struct AppState {
|
||||||
pub pool: PgPool,
|
pub pool: PgPool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn migrations(pool: sqlx::Pool) -> Result<(), sqlx::Error> {
|
pub async fn migrations(pool: &PgPool) -> Result<(), sqlx::Error> {
|
||||||
Migrator::new(Path::new("./migrations"))
|
Migrator::new(Path::new("./migrations"))
|
||||||
.await?
|
.await?
|
||||||
.run(pool)
|
.run(pool)
|
||||||
|
@ -36,26 +36,33 @@ pub async fn migrations(pool: sqlx::Pool) -> Result<(), sqlx::Error> {
|
||||||
#[actix_rt::main]
|
#[actix_rt::main]
|
||||||
async fn main() -> io::Result<()> {
|
async fn main() -> io::Result<()> {
|
||||||
let config = config::load(PathBuf::from("config.json"));
|
let config = config::load(PathBuf::from("config.json"));
|
||||||
|
|
||||||
let db_uri = &config.databases.postgres_uri.to_string();
|
let db_uri = &config.databases.postgres_uri.to_string();
|
||||||
|
|
||||||
let pool = PgPoolOptions::new()
|
let pool = PgPoolOptions::new()
|
||||||
.max_connections(100)
|
.max_connections(100)
|
||||||
.connect(db_uri)
|
.connect(db_uri)
|
||||||
.await
|
.await
|
||||||
.expect("Failed to connect to database");
|
.expect("Failed to connect to database");
|
||||||
migrations(pool).await;
|
|
||||||
|
migrations(&pool).await.expect("Failed to run migrations");
|
||||||
|
|
||||||
let address = format!(
|
let address = format!(
|
||||||
"{}:{}",
|
"{}:{}",
|
||||||
config.server.backend_host, config.server.backend_port
|
config.server.backend_host, config.server.backend_port
|
||||||
);
|
);
|
||||||
|
|
||||||
let paste_governor = GovernorConfigBuilder::default()
|
let paste_governor = GovernorConfigBuilder::default()
|
||||||
.per_second(config.ratelimits.seconds_in_between_pastes)
|
.per_second(config.ratelimits.seconds_in_between_pastes)
|
||||||
.burst_size(config.ratelimits.allowed_pastes_before_ratelimit)
|
.burst_size(config.ratelimits.allowed_pastes_before_ratelimit)
|
||||||
.finish()
|
.finish()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let state = AppState { config, pool };
|
let state = AppState { config, pool };
|
||||||
// migrate(db_uri, &include_dir!("migrations"))
|
// migrate(db_uri, &include_dir!("migrations"))
|
||||||
// .await
|
// .await
|
||||||
// .expect("Error in migrations!");
|
// .expect("Error in migrations!");
|
||||||
|
|
||||||
println!("🚀 zer0bin is running on {address}");
|
println!("🚀 zer0bin is running on {address}");
|
||||||
|
|
||||||
HttpServer::new(move || {
|
HttpServer::new(move || {
|
||||||
|
|
Loading…
Reference in New Issue