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:
parent
8fee150c41
commit
13e794a919
1 changed files with 8 additions and 5 deletions
|
@ -1,9 +1,9 @@
|
||||||
use diesel::{Identifiable, Insertable, Queryable, Selectable};
|
use diesel::{Identifiable, Insertable, Queryable, Selectable, Associations};
|
||||||
use diesel::pg::Pg;
|
use diesel::pg::Pg;
|
||||||
use super::schema::{users, telegram, discord, steam};
|
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(table_name = users)]
|
||||||
#[diesel(check_for_backend(Pg))]
|
#[diesel(check_for_backend(Pg))]
|
||||||
pub struct RoyalnetUser {
|
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(table_name = telegram)]
|
||||||
#[diesel(primary_key(telegram_id))]
|
#[diesel(primary_key(telegram_id))]
|
||||||
#[diesel(check_for_backend(Pg))]
|
#[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(table_name = discord)]
|
||||||
#[diesel(primary_key(discord_id))]
|
#[diesel(primary_key(discord_id))]
|
||||||
#[diesel(check_for_backend(Pg))]
|
#[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(table_name = steam)]
|
||||||
#[diesel(primary_key(steam_id))]
|
#[diesel(primary_key(steam_id))]
|
||||||
#[diesel(check_for_backend(Pg))]
|
#[diesel(check_for_backend(Pg))]
|
||||||
|
|
Loading…
Reference in a new issue