Skip to content

Commit 03d1905

Browse files
committed
fix(database): set correct collection id column type
Fixes #855.
1 parent 7b21d13 commit 03d1905

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/backend/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ryot"
3-
version = "5.5.4"
3+
version = "5.5.5"
44
edition = "2021"
55
repository = "https://github.com/IgnisDa/ryot"
66
license = "GPL-3.0"

libs/database/src/migrations/m20240509_create_user_to_collection.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use sea_orm_migration::prelude::*;
22

3+
use crate::get_whether_column_is_text;
4+
35
use super::{m20230417_create_user::User, m20230504_create_collection::Collection};
46

57
#[derive(DeriveMigrationName)]
@@ -15,16 +17,19 @@ pub enum UserToCollection {
1517
#[async_trait::async_trait]
1618
impl MigrationTrait for Migration {
1719
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
20+
let db = manager.get_connection();
21+
let mut base = ColumnDef::new(UserToCollection::CollectionId);
22+
let collection_column = if get_whether_column_is_text("collection", "id", db).await? {
23+
base.text()
24+
} else {
25+
base.integer()
26+
};
1827
manager
1928
.create_table(
2029
Table::create()
2130
.table(UserToCollection::Table)
2231
.col(ColumnDef::new(UserToCollection::UserId).integer())
23-
.col(
24-
ColumnDef::new(UserToCollection::CollectionId)
25-
.text()
26-
.not_null(),
27-
)
32+
.col(collection_column.not_null())
2833
.foreign_key(
2934
ForeignKey::create()
3035
.name("user_to_collection-fk1")

0 commit comments

Comments
 (0)