kalkutago/src/main.rs

37 lines
986 B
Rust
Raw Normal View History

2023-06-07 08:49:04 -04:00
#![feature(default_free_fn, proc_macro_hygiene, decl_macro)]
#[macro_use]
extern crate rocket;
mod api;
2023-06-06 10:27:02 -04:00
mod db;
2023-06-07 08:48:44 -04:00
mod entities;
2023-06-06 10:27:02 -04:00
mod error;
mod migrator;
2023-06-07 08:49:04 -04:00
use crate::migrator::Migrator;
2023-06-06 10:27:02 -04:00
use sea_orm::Database;
2023-06-06 12:46:35 -04:00
use sea_orm_migration::prelude::*;
2023-06-06 10:27:02 -04:00
2023-06-07 08:49:04 -04:00
#[launch]
async fn rocket_defines_the_main_fn() -> _ {
let url = db::connection_url();
let db = Database::connect(url).await.expect("db connection");
2023-06-06 12:46:35 -04:00
let schema_manager = SchemaManager::new(&db);
2023-06-07 08:49:04 -04:00
Migrator::refresh(&db).await.expect("migration");
assert!(schema_manager
.has_table("tracks")
.await
.expect("fetch tracks table"));
assert!(schema_manager
.has_table("ticks")
.await
.expect("fetch ticks table"));
assert!(schema_manager
.has_table("groups")
.await
.expect("fetch groups table"));
assert!(schema_manager
.has_table("track2_groups")
.await
.expect("fetch track2groups table"));
2023-06-08 07:49:46 -04:00
api::start_server(db)
2023-06-06 10:27:02 -04:00
}