Compare commits

...

2 Commits

Author SHA1 Message Date
0d6627d86a Add spot to parking space 2023-08-09 15:12:58 +02:00
c31776e46d Add spot to parking space 2023-08-09 14:56:46 +02:00
4 changed files with 55 additions and 2 deletions

View File

@ -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),
] ]
} }
} }

View File

@ -137,6 +137,7 @@ pub enum ParkingSpace {
Id, Id,
State, State,
Location, Location,
Spot,
AccountId, AccountId,
CreatedAt, CreatedAt,
UpdatedAt, UpdatedAt,

View 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(())
}
}

View File

@ -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!()
}