Compare commits
2 Commits
76090d4266
...
0d6627d86a
Author | SHA1 | Date | |
---|---|---|---|
0d6627d86a | |||
c31776e46d |
@ -6,6 +6,7 @@ mod m20220101_000001_create_table;
|
|||||||
mod m20230726_124452_images;
|
mod m20230726_124452_images;
|
||||||
mod m20230726_135630_parking_spaces;
|
mod m20230726_135630_parking_spaces;
|
||||||
mod m20230805_000001_add_email;
|
mod m20230805_000001_add_email;
|
||||||
|
mod m20230809_135630_add_spot;
|
||||||
|
|
||||||
pub struct Migrator;
|
pub struct Migrator;
|
||||||
|
|
||||||
@ -17,6 +18,7 @@ impl MigratorTrait for Migrator {
|
|||||||
Box::new(m20230726_124452_images::Migration),
|
Box::new(m20230726_124452_images::Migration),
|
||||||
Box::new(m20230726_135630_parking_spaces::Migration),
|
Box::new(m20230726_135630_parking_spaces::Migration),
|
||||||
Box::new(m20230805_000001_add_email::Migration),
|
Box::new(m20230805_000001_add_email::Migration),
|
||||||
|
Box::new(m20230809_135630_add_spot::Migration),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,6 +137,7 @@ pub enum ParkingSpace {
|
|||||||
Id,
|
Id,
|
||||||
State,
|
State,
|
||||||
Location,
|
Location,
|
||||||
|
Spot,
|
||||||
AccountId,
|
AccountId,
|
||||||
CreatedAt,
|
CreatedAt,
|
||||||
UpdatedAt,
|
UpdatedAt,
|
||||||
|
35
crates/migration/src/m20230809_135630_add_spot.rs
Normal file
35
crates/migration/src/m20230809_135630_add_spot.rs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
use sea_orm_migration::prelude::*;
|
||||||
|
|
||||||
|
use crate::m20230726_135630_parking_spaces::ParkingSpace;
|
||||||
|
|
||||||
|
#[derive(DeriveMigrationName)]
|
||||||
|
pub struct Migration;
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl MigrationTrait for Migration {
|
||||||
|
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
m.alter_table(
|
||||||
|
Table::alter()
|
||||||
|
.table(ParkingSpace::ParkingSpaces)
|
||||||
|
.add_column(
|
||||||
|
ColumnDef::new(ParkingSpace::Spot)
|
||||||
|
.integer())
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
m.alter_table(
|
||||||
|
Table::alter()
|
||||||
|
.table(ParkingSpace::ParkingSpaces)
|
||||||
|
.drop_column(ParkingSpace::Spot)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
use actix_web::get;
|
use actix_web::web::{scope, Data, Form, ServiceConfig};
|
||||||
use actix_web::web::{scope, Data, ServiceConfig};
|
use actix_web::{get, post, HttpResponse};
|
||||||
use askama_actix::Template;
|
use askama_actix::Template;
|
||||||
use oswilno_contract::accounts;
|
use oswilno_contract::accounts;
|
||||||
use oswilno_contract::parking_space_rents;
|
use oswilno_contract::parking_space_rents;
|
||||||
@ -100,3 +100,18 @@ async fn load_parking_spaces(db: Arc<DatabaseConnection>) -> AllParkingSpace {
|
|||||||
parking_space_by_id,
|
parking_space_by_id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, serde::Deserialize)]
|
||||||
|
struct CreateParkingSpace {
|
||||||
|
location: String,
|
||||||
|
spot: Option<u32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[post("/parking-spaces")]
|
||||||
|
async fn create(
|
||||||
|
db: Data<sea_orm::DatabaseConnection>,
|
||||||
|
p: Form<CreateParkingSpace>,
|
||||||
|
) -> HttpResponse {
|
||||||
|
let p = p.into_inner();
|
||||||
|
unreachable!()
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user