Skip to content

Commit

Permalink
chore:Setup diesel for database, prisma alternative for rust backend
Browse files Browse the repository at this point in the history
  • Loading branch information
DeveloperMindset123 committed Dec 28, 2024
1 parent 7c46392 commit 75a0892
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 0 deletions.
1 change: 1 addition & 0 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ actix-web = "4"
actix-web-actors = "4.3.1" # NOTE : deprecation warning
serde = "1.0.217"
serde_json = "1.0"
diesel = "2.2.6"
9 changes: 9 additions & 0 deletions server/diesel.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# For documentation on how to configure this file,
# see https://diesel.rs/guides/configuring-diesel-cli

[print_schema]
file = "src/schema.rs"
custom_type_derives = ["diesel::query_builder::QueryId", "Clone"]

[migrations_directory]
dir = "/Users/ayandas/Desktop/VS_Code_Projects/CCNY_SchedulePro/server/migrations"
99 changes: 99 additions & 0 deletions server/src/schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// @generated automatically by Diesel CLI.

diesel::table! {
RateMyProfessorComments (generated_id) {
professor_name -> Text,
department -> Text,
comments -> Nullable<Array<Nullable<Text>>>,
foreign_linker_id -> Text,
generated_id -> Text,
sentimentData -> Nullable<Array<Nullable<Jsonb>>>,
}
}

diesel::table! {
RateMyProfessorData (id) {
id -> Text,
department -> Text,
professorName -> Text,
avgDifficulty -> Float8,
avgRatings -> Float8,
wouldTakeAgain -> Text,
numRatings -> Int4,
}
}

diesel::table! {
RefreshTokens (id) {
id -> Text,
hashedToken -> Text,
userId -> Text,
revoked -> Bool,
createdAt -> Timestamp,
updatedAt -> Timestamp,
}
}

diesel::table! {
User (id) {
id -> Text,
email -> Text,
password -> Text,
createdAt -> Timestamp,
updatedAt -> Timestamp,
plainTextPassword -> Nullable<Text>,
}
}

diesel::table! {
UserRegistrationDetails (userID) {
userID -> Int4,
username -> Text,
major -> Text,
DOB -> Nullable<Text>,
CollegeYear -> Int4,
pronouns -> Nullable<Text>,
Hobbies -> Nullable<Text>,
Gender -> Text,
emailDuplicate -> Text,
degreeType -> Text,
}
}

diesel::table! {
_prisma_migrations (id) {
#[max_length = 36]
id -> Varchar,
#[max_length = 64]
checksum -> Varchar,
finished_at -> Nullable<Timestamptz>,
#[max_length = 255]
migration_name -> Varchar,
logs -> Nullable<Text>,
rolled_back_at -> Nullable<Timestamptz>,
started_at -> Timestamptz,
applied_steps_count -> Int4,
}
}

diesel::table! {
posts (id) {
id -> Int4,
title -> Varchar,
body -> Text,
published -> Bool,
}
}

diesel::joinable!(RateMyProfessorComments -> RateMyProfessorData (foreign_linker_id));
diesel::joinable!(RefreshTokens -> User (userId));

diesel::allow_tables_to_appear_in_same_query!(
RateMyProfessorComments,
RateMyProfessorData,
RefreshTokens,
User,
UserRegistrationDetails,
_prisma_migrations,
posts,
);

0 comments on commit 75a0892

Please sign in to comment.