Skip to content

Commit

Permalink
fix(database): set correct collection id column type
Browse files Browse the repository at this point in the history
Fixes #855.
  • Loading branch information
IgnisDa committed Jun 3, 2024
1 parent 7b21d13 commit 03d1905
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/backend/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ryot"
version = "5.5.4"
version = "5.5.5"
edition = "2021"
repository = "https://github.com/IgnisDa/ryot"
license = "GPL-3.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use sea_orm_migration::prelude::*;

use crate::get_whether_column_is_text;

use super::{m20230417_create_user::User, m20230504_create_collection::Collection};

#[derive(DeriveMigrationName)]
Expand All @@ -15,16 +17,19 @@ pub enum UserToCollection {
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
let db = manager.get_connection();
let mut base = ColumnDef::new(UserToCollection::CollectionId);
let collection_column = if get_whether_column_is_text("collection", "id", db).await? {
base.text()
} else {
base.integer()
};
manager
.create_table(
Table::create()
.table(UserToCollection::Table)
.col(ColumnDef::new(UserToCollection::UserId).integer())
.col(
ColumnDef::new(UserToCollection::CollectionId)
.text()
.not_null(),
)
.col(collection_column.not_null())
.foreign_key(
ForeignKey::create()
.name("user_to_collection-fk1")
Expand Down

0 comments on commit 03d1905

Please sign in to comment.