Skip to content

Commit

Permalink
Merge pull request #78 from ECDAR-AAU-SW-P5/76-model-should-be-rename…
Browse files Browse the repository at this point in the history
…d-to-project

76 model should be renamed to project
  • Loading branch information
sabotack authored Dec 6, 2023
2 parents 0efa8b5 + 6a09787 commit f84ebf0
Show file tree
Hide file tree
Showing 38 changed files with 1,163 additions and 1,141 deletions.
2 changes: 1 addition & 1 deletion Ecdar-ProtoBuf
Submodule Ecdar-ProtoBuf updated 2 files
+19 −19 api.proto
+5 −5 services.proto
4 changes: 2 additions & 2 deletions migration/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub use sea_orm_migration::prelude::*;

mod m20231012_094213_create_user_table;
mod m20231012_094228_create_model_table;
mod m20231012_094228_create_project_table;
mod m20231012_094242_create_query_table;
mod m20231012_094303_create_in_use_table;
mod m20231012_094422_create_session_table;
Expand All @@ -15,7 +15,7 @@ impl MigratorTrait for Migrator {
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
vec![
Box::new(m20231012_094213_create_user_table::Migration),
Box::new(m20231012_094228_create_model_table::Migration),
Box::new(m20231012_094228_create_project_table::Migration),
Box::new(m20231012_094242_create_query_table::Migration),
Box::new(m20231012_094422_create_session_table::Migration),
Box::new(m20231012_094303_create_in_use_table::Migration),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ impl MigrationTrait for Migration {
manager
.create_table(
Table::create()
.table(Model::Table)
.table(Project::Table)
.if_not_exists()
.col(
ColumnDef::new(Model::Id)
ColumnDef::new(Project::Id)
.integer()
.not_null()
.auto_increment()
.primary_key(),
)
.col(ColumnDef::new(Model::Name).string().not_null())
.col(ColumnDef::new(Model::ComponentsInfo).json().not_null())
.col(ColumnDef::new(Model::OwnerId).integer().not_null())
.col(ColumnDef::new(Project::Name).string().not_null())
.col(ColumnDef::new(Project::ComponentsInfo).json().not_null())
.col(ColumnDef::new(Project::OwnerId).integer().not_null())
.index(
Index::create()
.col(Model::OwnerId)
.col(Model::Name)
.col(Project::OwnerId)
.col(Project::Name)
.unique(),
)
.foreign_key(
ForeignKey::create()
.from(Model::Table, Model::OwnerId)
.from(Project::Table, Project::OwnerId)
.to(User::Table, User::Id)
.on_delete(ForeignKeyAction::Cascade),
)
Expand All @@ -42,13 +42,13 @@ impl MigrationTrait for Migration {

async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop().table(Model::Table).to_owned())
.drop_table(Table::drop().table(Project::Table).to_owned())
.await
}
}

#[derive(DeriveIden)]
pub enum Model {
pub enum Project {
Table,
Id,
Name,
Expand Down
10 changes: 5 additions & 5 deletions migration/src/m20231012_094242_create_query_table.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use sea_orm_migration::prelude::*;

use super::m20231012_094228_create_model_table::Model;
use super::m20231012_094228_create_project_table::Project;

#[derive(DeriveMigrationName)]
pub struct Migration;
Expand Down Expand Up @@ -28,11 +28,11 @@ impl MigrationTrait for Migration {
.not_null()
.default(true),
)
.col(ColumnDef::new(Query::ModelId).integer().not_null())
.col(ColumnDef::new(Query::ProjectId).integer().not_null())
.foreign_key(
ForeignKey::create()
.from(Query::Table, Query::ModelId)
.to(Model::Table, Model::Id)
.from(Query::Table, Query::ProjectId)
.to(Project::Table, Project::Id)
.on_delete(ForeignKeyAction::Cascade),
)
.to_owned(),
Expand All @@ -53,6 +53,6 @@ enum Query {
Id,
String,
Result,
ModelId,
ProjectId,
Outdated,
}
10 changes: 5 additions & 5 deletions migration/src/m20231012_094303_create_in_use_table.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use sea_orm_migration::prelude::*;

use super::m20231012_094228_create_model_table::Model;
use super::m20231012_094228_create_project_table::Project;
use super::m20231012_094422_create_session_table::Session;

#[derive(DeriveMigrationName)]
Expand All @@ -15,7 +15,7 @@ impl MigrationTrait for Migration {
.table(InUse::Table)
.if_not_exists()
.col(
ColumnDef::new(InUse::ModelId)
ColumnDef::new(InUse::ProjectId)
.integer()
.not_null()
.primary_key(),
Expand All @@ -29,8 +29,8 @@ impl MigrationTrait for Migration {
)
.foreign_key(
ForeignKey::create()
.from(InUse::Table, InUse::ModelId)
.to(Model::Table, Model::Id)
.from(InUse::Table, InUse::ProjectId)
.to(Project::Table, Project::Id)
.on_delete(ForeignKeyAction::Cascade),
)
.foreign_key(
Expand All @@ -54,7 +54,7 @@ impl MigrationTrait for Migration {
#[derive(DeriveIden)]
enum InUse {
Table,
ModelId,
ProjectId,
SessionId,
LatestActivity,
}
12 changes: 6 additions & 6 deletions migration/src/m20231012_094533_create_access_table.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use sea_orm_migration::prelude::*;

use super::m20231012_094213_create_user_table::User;
use super::m20231012_094228_create_model_table::Model;
use super::m20231012_094228_create_project_table::Project;
use super::m20231111_205633_create_role_table::Role;

#[derive(DeriveMigrationName)]
Expand All @@ -23,11 +23,11 @@ impl MigrationTrait for Migration {
.primary_key(),
)
.col(ColumnDef::new(Access::Role).string().not_null())
.col(ColumnDef::new(Access::ModelId).integer().not_null())
.col(ColumnDef::new(Access::ProjectId).integer().not_null())
.col(ColumnDef::new(Access::UserId).integer().not_null())
.index(
Index::create()
.col(Access::ModelId)
.col(Access::ProjectId)
.col(Access::UserId)
.unique(),
)
Expand All @@ -39,8 +39,8 @@ impl MigrationTrait for Migration {
)
.foreign_key(
ForeignKey::create()
.from(Access::Table, Access::ModelId)
.to(Model::Table, Model::Id)
.from(Access::Table, Access::ProjectId)
.to(Project::Table, Project::Id)
.on_delete(ForeignKeyAction::Cascade),
)
.foreign_key(
Expand All @@ -66,6 +66,6 @@ enum Access {
Id,
Table,
Role,
ModelId,
ProjectId,
UserId,
}
4 changes: 2 additions & 2 deletions src/api/context_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::api::hashing_context::HashingContextTrait;
use crate::api::server::server::ecdar_backend_server::EcdarBackend;
use crate::database::access_context::AccessContextTrait;
use crate::database::in_use_context::InUseContextTrait;
use crate::database::model_context::ModelContextTrait;
use crate::database::project_context::ProjectContextTrait;
use crate::database::query_context::QueryContextTrait;
use crate::database::session_context::SessionContextTrait;
use crate::database::user_context::UserContextTrait;
Expand All @@ -12,7 +12,7 @@ use std::sync::Arc;
pub struct ContextCollection {
pub(crate) access_context: Arc<dyn AccessContextTrait>,
pub(crate) in_use_context: Arc<dyn InUseContextTrait>,
pub(crate) model_context: Arc<dyn ModelContextTrait>,
pub(crate) project_context: Arc<dyn ProjectContextTrait>,
pub(crate) query_context: Arc<dyn QueryContextTrait>,
pub(crate) session_context: Arc<dyn SessionContextTrait>,
pub(crate) user_context: Arc<dyn UserContextTrait>,
Expand Down
Loading

0 comments on commit f84ebf0

Please sign in to comment.