mirror of
https://github.com/danbulant/Portfolio
synced 2026-05-19 04:18:52 +00:00
Merge pull request #18 from EETagent/small_dependencies_refactoring
Small dependencies refactoring
This commit is contained in:
commit
dd7386882b
19 changed files with 48 additions and 112 deletions
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "sea-orm-rocket-example"
|
||||
name = "portfolio"
|
||||
version = "0.1.0"
|
||||
authors = ["Vojtěch Jungmann", "Sebastian Pravda"]
|
||||
edition = "2021"
|
||||
|
|
|
|||
|
|
@ -5,22 +5,23 @@ edition = "2021"
|
|||
publish = false
|
||||
|
||||
[dependencies]
|
||||
rocket = { version = "^0.5.0-rc.2", features = [
|
||||
"json",
|
||||
] }
|
||||
|
||||
async-stream = { version = "^0.3" }
|
||||
async-trait = { version = "0.1" }
|
||||
futures = { version = "^0.3" }
|
||||
futures-util = { version = "^0.3" }
|
||||
rocket = { version = "0.5.0-rc.2", features = [
|
||||
"json",
|
||||
] }
|
||||
dotenv = "0.15.0"
|
||||
tokio = "^1.21"
|
||||
|
||||
serde_json = { version = "^1" }
|
||||
dotenv = "^0.15"
|
||||
|
||||
serde_json = { version = "^1.0" }
|
||||
|
||||
portfolio-entity = { path = "../entity" }
|
||||
portfolio-migration = { path = "../migration" }
|
||||
portfolio-core = { path = "../core" }
|
||||
|
||||
tokio = "1.21.2"
|
||||
|
||||
[dependencies.sea-orm-rocket]
|
||||
version = "0.5.1"
|
||||
version = "^0.5"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use portfolio_core::sea_orm;
|
|||
|
||||
use async_trait::async_trait;
|
||||
use sea_orm::ConnectOptions;
|
||||
use sea_orm_rocket::{rocket::figment::Figment, Config, Database};
|
||||
use sea_orm_rocket::{rocket::figment::Figment, Database};
|
||||
use std::time::Duration;
|
||||
|
||||
#[derive(Database, Debug)]
|
||||
|
|
@ -20,7 +20,7 @@ impl sea_orm_rocket::Pool for SeaOrmPool {
|
|||
|
||||
type Connection = sea_orm::DatabaseConnection;
|
||||
|
||||
async fn init(figment: &Figment) -> Result<Self, Self::Error> {
|
||||
async fn init(_figment: &Figment) -> Result<Self, Self::Error> {
|
||||
dotenv::dotenv().ok();
|
||||
let database_url = std::env::var("DATABASE_URL").unwrap();
|
||||
let mut options: ConnectOptions = database_url.into();
|
||||
|
|
|
|||
|
|
@ -2,29 +2,40 @@
|
|||
name = "portfolio-core"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
portfolio-entity = { path = "../entity" }
|
||||
rand = "0.8.5"
|
||||
chrono = "0.4.22"
|
||||
jsonwebtoken = "8.1.1"
|
||||
dotenv = "0.15.0"
|
||||
tokio = "1.21.2"
|
||||
futures = "0.3.25"
|
||||
async-compat = "0.2.1"
|
||||
chrono = "^0.4"
|
||||
|
||||
infer = "0.9"
|
||||
# serialization & deserialization
|
||||
serde = { version = "^1.0", features = ["derive"] }
|
||||
serde_json = "^1.0"
|
||||
|
||||
portfolio-entity = { path = "../entity" }
|
||||
|
||||
# tokens
|
||||
jsonwebtoken = "^8.1"
|
||||
|
||||
# env
|
||||
dotenv = "^0.15"
|
||||
|
||||
# async
|
||||
tokio = "^1.21"
|
||||
futures = "^0.3"
|
||||
async-compat = "^0.2"
|
||||
|
||||
# file identifier
|
||||
infer = "^0.9"
|
||||
|
||||
# crypto
|
||||
argon2 = { version = "0.4", features = ["std"] }
|
||||
age = { version = "0.9", features = ["async"] }
|
||||
secrecy = { version = "0.8.0" }
|
||||
base64 = "0.13"
|
||||
rand = "^0.8"
|
||||
argon2 = { version = "^0.4", features = ["std"] }
|
||||
age = { version = "^0.9", features = ["async"] }
|
||||
secrecy = { version = "^0.8" }
|
||||
base64 = "^0.13"
|
||||
|
||||
[dependencies.sea-orm]
|
||||
version = "^0.10.0"
|
||||
version = "^0.10"
|
||||
features = [
|
||||
"runtime-tokio-native-tls",
|
||||
"sqlx-postgres",
|
||||
|
|
@ -32,5 +43,5 @@ features = [
|
|||
]
|
||||
|
||||
[dev-dependencies]
|
||||
tokio = "1.21"
|
||||
async-tempfile = "0.2.0"
|
||||
tokio = "^1.21"
|
||||
async-tempfile = "^0.2"
|
||||
|
|
@ -9,10 +9,8 @@ name = "entity"
|
|||
path = "src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
rocket = { version = "0.5.0-rc.2", features = [
|
||||
"json",
|
||||
] }
|
||||
chrono = "0.4.22"
|
||||
serde = { version = "^1.0", features = ["derive"] }
|
||||
chrono = "^0.4"
|
||||
|
||||
[dependencies.sea-orm]
|
||||
version = "^0.10.0"
|
||||
version = "^0.10"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.3
|
||||
|
||||
use sea_orm::entity::prelude::*;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.3
|
||||
|
||||
use sea_orm::entity::prelude::*;
|
||||
use rocket::serde::{Deserialize, Serialize};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
|
||||
#[serde(crate = "rocket::serde")]
|
||||
#[sea_orm(table_name = "candidate")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key, auto_increment = false)]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.3
|
||||
|
||||
pub mod prelude;
|
||||
|
||||
pub mod admin;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.3
|
||||
|
||||
use sea_orm::entity::prelude::*;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.3
|
||||
|
||||
pub use super::admin::Entity as Admin;
|
||||
pub use super::candidate::Entity as Candidate;
|
||||
pub use super::parent::Entity as Parent;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.3
|
||||
|
||||
use sea_orm::entity::prelude::*;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
|
||||
|
|
|
|||
|
|
@ -9,11 +9,10 @@ name = "migration"
|
|||
path = "src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
rocket = { version = "0.5.0-rc.2" }
|
||||
async-std = { version = "^1", features = ["attributes", "tokio1"] }
|
||||
chrono = "0.4.22"
|
||||
serde = { version = "^1.0", features = ["derive"] }
|
||||
chrono = "^0.4"
|
||||
portfolio-entity = { path = "../entity" }
|
||||
|
||||
[dependencies.sea-orm-migration]
|
||||
version = "^0.10.0"
|
||||
version = "^0.10"
|
||||
features = [ "runtime-tokio-native-tls", "sqlx-postgres", "sqlx-sqlite"]
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
# Running Migrator CLI
|
||||
|
||||
- Apply all pending migrations
|
||||
```sh
|
||||
cargo run
|
||||
```
|
||||
```sh
|
||||
cargo run -- up
|
||||
```
|
||||
- Apply first 10 pending migrations
|
||||
```sh
|
||||
cargo run -- up -n 10
|
||||
```
|
||||
- Rollback last applied migrations
|
||||
```sh
|
||||
cargo run -- down
|
||||
```
|
||||
- Rollback last 10 applied migrations
|
||||
```sh
|
||||
cargo run -- down -n 10
|
||||
```
|
||||
- Drop all tables from the database, then reapply all migrations
|
||||
```sh
|
||||
cargo run -- fresh
|
||||
```
|
||||
- Rollback all applied migrations, then reapply all migrations
|
||||
```sh
|
||||
cargo run -- refresh
|
||||
```
|
||||
- Rollback all applied migrations
|
||||
```sh
|
||||
cargo run -- reset
|
||||
```
|
||||
- Check the status of all migrations
|
||||
```sh
|
||||
cargo run -- status
|
||||
```
|
||||
|
|
@ -36,7 +36,6 @@ impl MigrationTrait for Migration {
|
|||
}
|
||||
}
|
||||
|
||||
/// Learn more at https://docs.rs/sea-query#iden
|
||||
#[derive(Iden)]
|
||||
enum Admin {
|
||||
Table,
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ impl MigrationTrait for Migration {
|
|||
}
|
||||
}
|
||||
|
||||
/// Learn more at https://docs.rs/sea-query#iden
|
||||
#[derive(Iden)]
|
||||
pub enum Candidate {
|
||||
Table,
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ impl MigrationTrait for Migration {
|
|||
}
|
||||
}
|
||||
|
||||
/// Learn more at https://docs.rs/sea-query#iden
|
||||
#[derive(Iden)]
|
||||
enum Parent {
|
||||
Table,
|
||||
|
|
|
|||
|
|
@ -40,8 +40,6 @@ impl MigrationTrait for Migration {
|
|||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
let db = manager.get_connection();
|
||||
|
||||
print!("{:?}", self.admin.clone().id);
|
||||
|
||||
self.admin.to_owned().delete(db).await?;
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ impl MigrationTrait for Migration {
|
|||
}
|
||||
}
|
||||
|
||||
/// Learn more at https://docs.rs/sea-query#iden
|
||||
#[derive(Iden)]
|
||||
pub enum Session {
|
||||
Table,
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
use sea_orm_migration::prelude::*;
|
||||
|
||||
#[async_std::main]
|
||||
async fn main() {
|
||||
// Setting `DATABASE_URL` environment variable
|
||||
let key = "DATABASE_URL";
|
||||
if std::env::var(key).is_err() {
|
||||
// Getting the database URL from Rocket.toml if it's not set
|
||||
let figment = rocket::Config::figment();
|
||||
let database_url: String = figment
|
||||
.extract_inner("databases.sea_orm.url")
|
||||
.expect("Cannot find Database URL in Rocket.toml");
|
||||
std::env::set_var(key, database_url);
|
||||
}
|
||||
|
||||
cli::run_cli(migration::Migrator).await;
|
||||
}
|
||||
Loading…
Reference in a new issue