From b712f96f59a687078e7341479bb5a0129852c653 Mon Sep 17 00:00:00 2001 From: Awiteb Date: Tue, 9 Jul 2024 14:09:03 +0300 Subject: [PATCH] change: Change the user id from `integer` to `bigint` Signed-off-by: Awiteb --- crates/oxidetalis_entities/src/blacklist.rs | 5 +++-- crates/oxidetalis_entities/src/incoming_chat_requests.rs | 5 +++-- crates/oxidetalis_entities/src/outgoing_chat_requests.rs | 5 +++-- crates/oxidetalis_entities/src/prelude.rs | 3 +++ crates/oxidetalis_entities/src/users.rs | 3 ++- crates/oxidetalis_entities/src/whitelist.rs | 5 +++-- crates/oxidetalis_migrations/src/create_blacklist_table.rs | 4 ++-- .../src/create_incoming_chat_requests_table.rs | 4 ++-- .../src/create_outgoing_chat_requests_table.rs | 4 ++-- crates/oxidetalis_migrations/src/create_users_table.rs | 2 +- crates/oxidetalis_migrations/src/create_whitelist_table.rs | 4 ++-- 11 files changed, 26 insertions(+), 18 deletions(-) diff --git a/crates/oxidetalis_entities/src/blacklist.rs b/crates/oxidetalis_entities/src/blacklist.rs index 6d955a6..30b5ad2 100644 --- a/crates/oxidetalis_entities/src/blacklist.rs +++ b/crates/oxidetalis_entities/src/blacklist.rs @@ -23,13 +23,14 @@ use chrono::Utc; use sea_orm::entity::prelude::*; use super::users::Entity as UserEntity; +use crate::prelude::UserId; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "blacklist")] pub struct Model { #[sea_orm(primary_key)] - pub id: i32, - pub user_id: i32, + pub id: UserId, + pub user_id: UserId, /// Public key of the target pub target: String, pub blacklisted_at: chrono::DateTime, diff --git a/crates/oxidetalis_entities/src/incoming_chat_requests.rs b/crates/oxidetalis_entities/src/incoming_chat_requests.rs index 5e34c7e..d3e16e4 100644 --- a/crates/oxidetalis_entities/src/incoming_chat_requests.rs +++ b/crates/oxidetalis_entities/src/incoming_chat_requests.rs @@ -23,13 +23,14 @@ use chrono::Utc; use sea_orm::entity::prelude::*; use super::users::Entity as UserEntity; +use crate::prelude::UserId; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "in_chat_requests")] pub struct Model { #[sea_orm(primary_key)] - pub id: i32, - pub recipient_id: i32, + pub id: UserId, + pub recipient_id: UserId, /// Public key of the sender pub sender: String, /// The timestamp of the request, when it was received diff --git a/crates/oxidetalis_entities/src/outgoing_chat_requests.rs b/crates/oxidetalis_entities/src/outgoing_chat_requests.rs index 35a92b7..6df5ed0 100644 --- a/crates/oxidetalis_entities/src/outgoing_chat_requests.rs +++ b/crates/oxidetalis_entities/src/outgoing_chat_requests.rs @@ -23,13 +23,14 @@ use chrono::Utc; use sea_orm::entity::prelude::*; use super::users::Entity as UserEntity; +use crate::prelude::UserId; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "out_chat_requests")] pub struct Model { #[sea_orm(primary_key)] - pub id: i32, - pub sender_id: i32, + pub id: UserId, + pub sender_id: UserId, /// Public key of the recipient pub recipient: String, /// The timestamp of the request, when it was sent diff --git a/crates/oxidetalis_entities/src/prelude.rs b/crates/oxidetalis_entities/src/prelude.rs index 6d045cb..67477f1 100644 --- a/crates/oxidetalis_entities/src/prelude.rs +++ b/crates/oxidetalis_entities/src/prelude.rs @@ -33,6 +33,9 @@ pub use sea_orm::{ SqlErr, }; +/// User ID type +pub type UserId = i64; + pub use super::blacklist::{ ActiveModel as BlacklistActiveModel, Column as BlacklistColumn, diff --git a/crates/oxidetalis_entities/src/users.rs b/crates/oxidetalis_entities/src/users.rs index c4bf38a..f33a285 100644 --- a/crates/oxidetalis_entities/src/users.rs +++ b/crates/oxidetalis_entities/src/users.rs @@ -25,12 +25,13 @@ use super::blacklist::Entity as BlacklistEntity; use super::incoming_chat_requests::Entity as InChatRequestsEntity; use super::outgoing_chat_requests::Entity as OutChatRequestsEntity; use super::whitelist::Entity as WhitelistEntity; +use crate::prelude::UserId; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "users")] pub struct Model { #[sea_orm(primary_key)] - pub id: i32, + pub id: UserId, pub public_key: String, pub is_admin: bool, } diff --git a/crates/oxidetalis_entities/src/whitelist.rs b/crates/oxidetalis_entities/src/whitelist.rs index 2a72197..1f4d944 100644 --- a/crates/oxidetalis_entities/src/whitelist.rs +++ b/crates/oxidetalis_entities/src/whitelist.rs @@ -23,13 +23,14 @@ use chrono::Utc; use sea_orm::entity::prelude::*; use super::users::Entity as UserEntity; +use crate::prelude::UserId; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "whitelist")] pub struct Model { #[sea_orm(primary_key)] - pub id: i32, - pub user_id: i32, + pub id: UserId, + pub user_id: UserId, /// Public key of the target pub target: String, pub whitelisted_at: chrono::DateTime, diff --git a/crates/oxidetalis_migrations/src/create_blacklist_table.rs b/crates/oxidetalis_migrations/src/create_blacklist_table.rs index e459d2e..2eaf805 100644 --- a/crates/oxidetalis_migrations/src/create_blacklist_table.rs +++ b/crates/oxidetalis_migrations/src/create_blacklist_table.rs @@ -34,12 +34,12 @@ impl MigrationTrait for Migration { .if_not_exists() .col( ColumnDef::new(Blacklist::Id) - .integer() + .big_integer() .not_null() .auto_increment() .primary_key(), ) - .col(ColumnDef::new(Blacklist::UserId).integer().not_null()) + .col(ColumnDef::new(Blacklist::UserId).big_integer().not_null()) .col(ColumnDef::new(Blacklist::Target).string().not_null()) .col(ColumnDef::new(Blacklist::Reason).string_len(400)) .col( diff --git a/crates/oxidetalis_migrations/src/create_incoming_chat_requests_table.rs b/crates/oxidetalis_migrations/src/create_incoming_chat_requests_table.rs index b9e1ca5..7289225 100644 --- a/crates/oxidetalis_migrations/src/create_incoming_chat_requests_table.rs +++ b/crates/oxidetalis_migrations/src/create_incoming_chat_requests_table.rs @@ -34,14 +34,14 @@ impl MigrationTrait for Migration { .if_not_exists() .col( ColumnDef::new(InChatRequests::Id) - .integer() + .big_integer() .not_null() .auto_increment() .primary_key(), ) .col( ColumnDef::new(InChatRequests::RecipientId) - .integer() + .big_integer() .not_null(), ) .col(ColumnDef::new(InChatRequests::Sender).string().not_null()) diff --git a/crates/oxidetalis_migrations/src/create_outgoing_chat_requests_table.rs b/crates/oxidetalis_migrations/src/create_outgoing_chat_requests_table.rs index 3db083c..7db4b81 100644 --- a/crates/oxidetalis_migrations/src/create_outgoing_chat_requests_table.rs +++ b/crates/oxidetalis_migrations/src/create_outgoing_chat_requests_table.rs @@ -34,14 +34,14 @@ impl MigrationTrait for Migration { .if_not_exists() .col( ColumnDef::new(OutChatRequests::Id) - .integer() + .big_integer() .not_null() .auto_increment() .primary_key(), ) .col( ColumnDef::new(OutChatRequests::SenderId) - .integer() + .big_integer() .not_null(), ) .col( diff --git a/crates/oxidetalis_migrations/src/create_users_table.rs b/crates/oxidetalis_migrations/src/create_users_table.rs index 71e771e..6e1b671 100644 --- a/crates/oxidetalis_migrations/src/create_users_table.rs +++ b/crates/oxidetalis_migrations/src/create_users_table.rs @@ -34,7 +34,7 @@ impl MigrationTrait for Migration { .if_not_exists() .col( ColumnDef::new(Users::Id) - .integer() + .big_integer() .not_null() .auto_increment() .primary_key(), diff --git a/crates/oxidetalis_migrations/src/create_whitelist_table.rs b/crates/oxidetalis_migrations/src/create_whitelist_table.rs index 027c363..d29f837 100644 --- a/crates/oxidetalis_migrations/src/create_whitelist_table.rs +++ b/crates/oxidetalis_migrations/src/create_whitelist_table.rs @@ -34,12 +34,12 @@ impl MigrationTrait for Migration { .if_not_exists() .col( ColumnDef::new(Whitelist::Id) - .integer() + .big_integer() .not_null() .auto_increment() .primary_key(), ) - .col(ColumnDef::new(Whitelist::UserId).integer().not_null()) + .col(ColumnDef::new(Whitelist::UserId).big_integer().not_null()) .col(ColumnDef::new(Whitelist::Target).string().not_null()) .col( ColumnDef::new(Whitelist::WhitelistedAt)