refactor: change ip address inet type to string

This commit is contained in:
Sebastian Pravda 2022-10-29 12:24:45 +02:00
parent 5e36b7b3c8
commit 98110dcf96
No known key found for this signature in database
GPG key ID: F3BC84F08EFA3F57
3 changed files with 2 additions and 20 deletions

View file

@ -2,7 +2,7 @@ use chrono::Duration;
use entity::candidate;
use sea_orm::{DatabaseConnection, prelude::Uuid, ModelTrait};
use crate::{crypto::{self, hash_sha256}, Query, token::{generate_candidate_token, candidate_token::CandidateToken}, error::{ServiceError, USER_NOT_FOUND_ERROR, INVALID_CREDENTIALS_ERROR, DB_ERROR, USER_NOT_FOUND_BY_JWT_ID, USER_NOT_FOUND_BY_SESSION_ID}, Mutation};
use crate::{crypto::{self}, Query, token::{generate_candidate_token, candidate_token::CandidateToken}, error::{ServiceError, USER_NOT_FOUND_ERROR, INVALID_CREDENTIALS_ERROR, DB_ERROR, USER_NOT_FOUND_BY_JWT_ID, USER_NOT_FOUND_BY_SESSION_ID}, Mutation};
pub struct CandidateService;

View file

@ -8,7 +8,6 @@ pub struct Model {
#[sea_orm(primary_key, auto_increment = false)]
pub id: Uuid,
pub user_id: i32,
#[sea_orm(column_type = "Custom(\"inet\".to_owned())")]
pub ip_address: String,
pub created_at: DateTime,
pub expires_at: DateTime,

View file

@ -1,28 +1,11 @@
use sea_orm_migration::prelude::*;
use crate::m20221024_121621_create_candidate::Candidate;
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
let table = Table::create()
.table(Session::Table)
.if_not_exists()
.col(
ColumnDef::new(Session::Id)
.uuid()
.not_null()
.unique_key()
.primary_key(),
)
.col(ColumnDef::new(Session::UserId).integer().not_null())
.col(ColumnDef::new(Session::CreatedAt).date_time().not_null())
.col(ColumnDef::new(Session::ExpiresAt).date_time().not_null())
.to_owned();
manager
.create_table(
Table::create()
@ -36,7 +19,7 @@ impl MigrationTrait for Migration {
.primary_key(),
)
.col(ColumnDef::new(Session::UserId).integer().not_null())
.col(ColumnDef::new(Session::IpAddress).inet().not_null())
.col(ColumnDef::new(Session::IpAddress).string().not_null())
.col(ColumnDef::new(Session::CreatedAt).date_time().not_null())
.col(ColumnDef::new(Session::ExpiresAt).date_time().not_null())
.to_owned(),