-
Notifications
You must be signed in to change notification settings - Fork 2
Create and document an MVP DB schema using DBML #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
2004883
Creates/documents the MVP DB schema for refactor_platform_rs using DBML
jhodapp dde0807
Change the DB schema to just refactor_platform
jhodapp 4b2a48f
Update coaching_relationship comment
jhodapp ca5a685
Update README.md new database creation SQL to use refactor_platform s…
jhodapp 9de6e9f
Added logo URI field to organizations
jhodapp 90bd8f7
Add a URL to users capturing their github profile URL
jhodapp f126cb6
run sql file as base_migration
calebbourg b9a41dd
fixup
calebbourg e95bfa7
Make the rebuild.sh script more OS-agnostic. Also migrate the codebas…
jhodapp 1573745
Move the tower-sessions DB table into the refactor_platform schema an…
jhodapp afdfed5
Remove the sqlite feature from sqlx since we don't use it.
jhodapp fd817af
add external_id to tables
calebbourg b6b64cc
generate new entities using seaORM CLI
calebbourg 69bfdcb
Clean up a warning and code formatting
jhodapp 1a5ac07
Update the DB schema diagram to be in sync with refactor_platform_rs.…
jhodapp 0329eee
Integer-based primary keys seem to need to be i32 (INT4 SQL type) for…
jhodapp cf8fe3d
Ran cargo fmt
jhodapp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/target | ||
dbml-error.log |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
// Use DBML to define your database structure | ||
// Docs: https://dbml.dbdiagram.io/docs | ||
|
||
Table refactor_platform.organizations { | ||
id integer [primary key, unique, not null, increment] | ||
external_id uuid [unique, not null, default: `gen_random_uuid()`, note: 'The publicly visible identifier for a record'] | ||
name varchar [note: 'The name of the organization that the coach <--> coachee belong to'] | ||
logo varchar [note: 'A URI pointing to the organization\'s logo icon file'] | ||
created_at timestamptz [default: `now()`] | ||
updated_at timestamptz [default: `now()`, note: 'The last date and time fields were changed'] | ||
} | ||
|
||
// Coaching relationship type belonging to the refactor_platform schema | ||
// from the perspective of the coach | ||
Table refactor_platform.coaching_relationships { | ||
id integer [primary key, unique, not null, increment] | ||
external_id uuid [unique, not null, default: `gen_random_uuid()`, note: 'The publicly visible identifier for a record'] | ||
organization_id integer [not null, note: 'The organization associated with this coaching relationship'] | ||
coach_id integer [not null, note: 'The coach associated with this coaching relationship'] | ||
coachee_id integer [not null, note: 'The coachee associated with this coaching relationship'] | ||
created_at timestamptz [default: `now()`] | ||
updated_at timestamptz [default: `now()`, note: 'The last date and time fields were changed'] | ||
} | ||
|
||
Table refactor_platform.users { | ||
id integer [primary key, unique, not null, increment] | ||
external_id uuid [unique, not null, default: `gen_random_uuid()`, note: 'The publicly visible identifier for a record'] | ||
email varchar [unique, not null] | ||
first_name varchar | ||
last_name varchar | ||
display_name varchar [note: 'If a user wants to go by something other than first & last names'] | ||
password varchar | ||
github_username varchar // Specifically GH for now, can generalize later | ||
github_profile_url varchar | ||
created_at timestamptz [default: `now()`] | ||
updated_at timestamptz [default: `now()`, note: 'The last date and time fields were changed'] | ||
} | ||
|
||
Table refactor_platform.coaching_sessions { | ||
id integer [primary key, unique, not null, increment] | ||
external_id uuid [unique, not null, default: `gen_random_uuid()`, note: 'The publicly visible identifier for a record'] | ||
coaching_relationship_id integer [not null, note: 'The coaching relationship (i.e. what coach & coachee under what organization) associated with this coaching session'] | ||
date timestamp [note: 'The date and time of a session'] | ||
timezone varchar [note: 'The baseline timezone used for the `date` field'] | ||
created_at timestamptz [default: `now()`] | ||
updated_at timestamptz [default: `now()`, note: 'The last date and time fields were changed'] | ||
} | ||
|
||
Table refactor_platform.overarching_goals { | ||
id integer [primary key, unique, not null, increment] | ||
external_id uuid [unique, not null, default: `gen_random_uuid()`, note: 'The publicly visible identifier for a record'] | ||
coaching_session_id integer [note: 'The coaching session that an overarching goal is associated with'] | ||
title varchar [note: 'A short description of an overarching goal'] | ||
details varchar [note: 'A long description of an overarching goal'] | ||
completed_at timestamptz [note: 'The date and time an overarching goal was completed'] | ||
created_at timestamptz [default: `now()`] | ||
updated_at timestamptz [default: `now()`, note: 'The last date and time fields were changed'] | ||
} | ||
|
||
Table refactor_platform.notes { | ||
calebbourg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
id integer [primary key, unique, not null, increment] | ||
external_id uuid [unique, not null, default: `gen_random_uuid()`, note: 'The publicly visible identifier for a record'] | ||
coaching_session_id integer [not null] | ||
body varchar [note: 'Main text of the note supporting Markdown'] | ||
calebbourg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
user_id integer [not null, note: 'User that created (owns) the note'] | ||
created_at timestamptz [default: `now()`] | ||
updated_at timestamptz [default: `now()`, note: 'The last date and time an overarching note\'s fields were changed'] | ||
} | ||
|
||
Table refactor_platform.agreements { | ||
id integer [primary key, unique, not null, increment] | ||
external_id uuid [unique, not null, default: `gen_random_uuid()`, note: 'The publicly visible identifier for a record'] | ||
coaching_session_id integer [not null] | ||
details varchar [note: 'Either a short or long description of an agreement reached between coach and coachee in a coaching session'] | ||
user_id integer [not null, note: 'User that created (owns) the agreement'] | ||
created_at timestamptz [default: `now()`] | ||
updated_at timestamptz [default: `now()`, note: 'The last date and time an overarching agreement\'s fields were changed'] | ||
} | ||
|
||
Table refactor_platform.actions { | ||
id integer [primary key, unique, not null, increment] | ||
external_id uuid [unique, not null, default: `gen_random_uuid()`, note: 'The publicly visible identifier for a record'] | ||
// The first session where this action was created | ||
// It will carry forward to every future session until | ||
// its due_by is passed or it was completed by the coachee | ||
coaching_session_id integer [not null] | ||
due_by timestamptz | ||
completed boolean // May be unnecessary if there's a valid completed_at timestamp | ||
completed_at timestamptz | ||
created_at timestamp [default: `now()`] | ||
updated_at timestamp [default: `now()`] | ||
} | ||
|
||
// coaching_relationships relationships | ||
Ref: refactor_platform.coaching_relationships.organization_id > refactor_platform.organizations.id | ||
Ref: refactor_platform.coaching_relationships.coachee_id > refactor_platform.users.id | ||
Ref: refactor_platform.coaching_relationships.coach_id > refactor_platform.users.id | ||
|
||
// coaching_sessions relationships | ||
Ref: refactor_platform.coaching_sessions.coaching_relationship_id > refactor_platform.coaching_relationships.id | ||
|
||
// overarching_goals relationships | ||
Ref: refactor_platform.overarching_goals.coaching_session_id > refactor_platform.coaching_sessions.id | ||
|
||
// notes relationships | ||
Ref: refactor_platform.notes.coaching_session_id > refactor_platform.coaching_sessions.id | ||
Ref: refactor_platform.notes.user_id > refactor_platform.users.id | ||
|
||
// agreements relationships | ||
Ref: refactor_platform.agreements.coaching_session_id > refactor_platform.coaching_sessions.id | ||
Ref: refactor_platform.agreements.user_id > refactor_platform.users.id | ||
|
||
// actions relationships | ||
Ref: refactor_platform.actions.coaching_session_id > refactor_platform.coaching_sessions.id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.3 | ||
|
||
use sea_orm::entity::prelude::*; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] | ||
#[sea_orm(schema_name = "refactor_platform", table_name = "actions")] | ||
pub struct Model { | ||
#[sea_orm(primary_key)] | ||
#[serde(skip_deserializing)] | ||
pub id: i32, | ||
#[sea_orm(unique)] | ||
pub external_id: Uuid, | ||
pub coaching_session_id: i32, | ||
pub due_by: Option<DateTimeWithTimeZone>, | ||
pub completed: Option<bool>, | ||
pub completed_at: Option<DateTimeWithTimeZone>, | ||
pub created_at: Option<DateTime>, | ||
pub updated_at: Option<DateTime>, | ||
} | ||
|
||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] | ||
pub enum Relation { | ||
#[sea_orm( | ||
belongs_to = "super::coaching_sessions::Entity", | ||
from = "Column::CoachingSessionId", | ||
to = "super::coaching_sessions::Column::Id", | ||
on_update = "NoAction", | ||
on_delete = "NoAction" | ||
)] | ||
CoachingSessions, | ||
} | ||
|
||
impl Related<super::coaching_sessions::Entity> for Entity { | ||
fn to() -> RelationDef { | ||
Relation::CoachingSessions.def() | ||
} | ||
} | ||
|
||
impl ActiveModelBehavior for ActiveModel {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.3 | ||
|
||
use sea_orm::entity::prelude::*; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] | ||
#[sea_orm(schema_name = "refactor_platform", table_name = "agreements")] | ||
pub struct Model { | ||
#[sea_orm(primary_key)] | ||
#[serde(skip_deserializing)] | ||
pub id: i32, | ||
#[sea_orm(unique)] | ||
pub external_id: Uuid, | ||
pub coaching_session_id: i32, | ||
pub details: Option<String>, | ||
pub user_id: i32, | ||
pub created_at: Option<DateTimeWithTimeZone>, | ||
pub updated_at: Option<DateTimeWithTimeZone>, | ||
} | ||
|
||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] | ||
pub enum Relation { | ||
#[sea_orm( | ||
belongs_to = "super::coaching_sessions::Entity", | ||
from = "Column::CoachingSessionId", | ||
to = "super::coaching_sessions::Column::Id", | ||
on_update = "NoAction", | ||
on_delete = "NoAction" | ||
)] | ||
CoachingSessions, | ||
#[sea_orm( | ||
belongs_to = "super::users::Entity", | ||
from = "Column::UserId", | ||
to = "super::users::Column::Id", | ||
on_update = "NoAction", | ||
on_delete = "NoAction" | ||
)] | ||
Users, | ||
} | ||
|
||
impl Related<super::coaching_sessions::Entity> for Entity { | ||
fn to() -> RelationDef { | ||
Relation::CoachingSessions.def() | ||
} | ||
} | ||
|
||
impl Related<super::users::Entity> for Entity { | ||
fn to() -> RelationDef { | ||
Relation::Users.def() | ||
} | ||
} | ||
|
||
impl ActiveModelBehavior for ActiveModel {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.