Friends functionality (#90)

### Description

Implements and closes #86

### Game

Robocraft

### Please confirm

- [x] I am the legal owner or represent the owner of all work submitted
- [x] I consent to my submission being added to this FOSS project
- [ ] This PR used LLMs to generate some or all of the code changes

Reviewed-on: https://git.ngram.ca/OpenJam/rc-servers/pulls/90
Co-authored-by: NG (Graham) <ngniusness@gmail.com>
Co-committed-by: NG (Graham) <ngniusness@gmail.com>
This commit is contained in:
NG (Graham) authored and NGnius committed 2026-02-16 04:28:14 +00:00
1 parent 872f224af6
commit 9502522ac4
30 files changed
+1108 -35

No files matched your search

@@ -0,0 +1,53 @@
use sea_orm_migration::prelude::*;
pub struct Migration;
impl MigrationName for Migration {
fn name(&self) -> &str {
"m20260215_000001_create_friend_table"
}
}
#[async_trait::async_trait]
impl MigrationTrait for Migration {
// Define how to apply this migration: Create the Friends table.
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
Table::create()
.table(crate::schema::friend::Entity)
.col(
ColumnDef::new(crate::schema::friend::Column::Id)
.integer()
.not_null()
.auto_increment()
.primary_key(),
)
.col(ColumnDef::new(crate::schema::factory::vehicle::Column::CreationTime).big_integer().not_null())
.col(ColumnDef::new(crate::schema::friend::Column::FriendSource).integer().not_null())
.foreign_key(
ForeignKey::create()
.name("fk-friends-friend_source")
.from(crate::schema::friend::Entity, crate::schema::friend::Column::FriendSource)
.to(crate::schema::user::Entity, crate::schema::user::Column::Id),
)
.col(ColumnDef::new(crate::schema::friend::Column::FriendTarget).integer().not_null())
.foreign_key(
ForeignKey::create()
.name("fk-friends-friend_target")
.from(crate::schema::friend::Entity, crate::schema::friend::Column::FriendTarget)
.to(crate::schema::user::Entity, crate::schema::user::Column::Id),
)
.col(ColumnDef::new(crate::schema::friend::Column::State).string().not_null())
.to_owned(),
)
.await
}
// Define how to rollback this migration: Drop the Friends table.
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop().table(crate::schema::friend::Entity).to_owned())
.await
}
}
+2
View File
@@ -15,6 +15,7 @@ mod m20250918_000001_add_player_variant;
mod m20251228_000001_create_score_table;
#[cfg(feature = "factory")]
mod m20260126_000001_create_factory_vehicle_table;
mod m20260215_000001_create_friend_table;
pub struct Migrator;
@@ -37,6 +38,7 @@ impl MigratorTrait for Migrator {
Box::new(m20251228_000001_create_score_table::Migration),
#[cfg(feature = "factory")]
Box::new(m20260126_000001_create_factory_vehicle_table::Migration),
Box::new(m20260215_000001_create_friend_table::Migration),
]
}
}