1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-24 20:14:19 +00:00

Add associations to all database models

This commit is contained in:
Steffo 2024-07-08 06:18:09 +02:00
parent 8fee150c41
commit 13e794a919
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0

View file

@ -1,9 +1,9 @@
use diesel::{Identifiable, Insertable, Queryable, Selectable};
use diesel::{Identifiable, Insertable, Queryable, Selectable, Associations};
use diesel::pg::Pg;
use super::schema::{users, telegram, discord, steam};
#[derive(Debug, Clone, Identifiable, Queryable, Selectable, Insertable)]
#[derive(Debug, Clone, PartialEq, Identifiable, Queryable, Selectable, Insertable)]
#[diesel(table_name = users)]
#[diesel(check_for_backend(Pg))]
pub struct RoyalnetUser {
@ -12,7 +12,8 @@ pub struct RoyalnetUser {
}
#[derive(Debug, Clone, Identifiable, Queryable, Selectable, Insertable)]
#[derive(Debug, Clone, PartialEq, Identifiable, Queryable, Selectable, Insertable, Associations)]
#[diesel(belongs_to(RoyalnetUser, foreign_key = user_id))]
#[diesel(table_name = telegram)]
#[diesel(primary_key(telegram_id))]
#[diesel(check_for_backend(Pg))]
@ -22,7 +23,8 @@ pub struct TelegramUser {
}
#[derive(Debug, Clone, Identifiable, Queryable, Selectable, Insertable)]
#[derive(Debug, Clone, PartialEq, Identifiable, Queryable, Selectable, Insertable, Associations)]
#[diesel(belongs_to(RoyalnetUser, foreign_key = user_id))]
#[diesel(table_name = discord)]
#[diesel(primary_key(discord_id))]
#[diesel(check_for_backend(Pg))]
@ -32,7 +34,8 @@ pub struct DiscordUser {
}
#[derive(Debug, Clone, Identifiable, Queryable, Selectable, Insertable)]
#[derive(Debug, Clone, PartialEq, Identifiable, Queryable, Selectable, Insertable, Associations)]
#[diesel(belongs_to(RoyalnetUser, foreign_key = user_id))]
#[diesel(table_name = steam)]
#[diesel(primary_key(steam_id))]
#[diesel(check_for_backend(Pg))]