• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

doitsu2014 / my-cms / 14187034714

01 Apr 2025 04:12AM UTC coverage: 59.597% (+20.5%) from 39.058%
14187034714

push

github

web-flow
Feature/support multi language (#19)

* Enhance entity structure: add category and post translations, update migration dependencies, and improve README guidelines

* Add support for category translations: update create and modify handlers, requests, and tests

add TODO

* Add category translations support: update create, modify, and read handlers, and adjust request structures

* Refactor category translation requests: remove slug field and update handlers to set category ID for translations

* Add support for post translations: update create and modify requests, handlers, and models

* Update CI configuration and scripts for improved coverage reporting and toolchain management

* Update coverage configuration and scripts for improved reporting and toolchain management

* Update CI and coverage configurations for improved reporting and ignore patterns

* Update CI configuration and coverage scripts for improved reporting and cleanup

* Remove unused coverage step from CI configuration

* Update CI configuration to use fixed lcov report paths for coverage uploads

197 of 396 new or added lines in 19 files covered. (49.75%)

71 existing lines in 11 files now uncovered.

975 of 1636 relevant lines covered (59.6%)

26.2 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.56
/migration/src/m20250330_151455_release_110.rs
1
use sea_orm_migration::prelude::*;
2

3
use crate::{
4
    m20240409_151952_release_100::{Categories, Posts},
5
    NAME_LENGTH, TITLE_LENGTH,
6
};
7

8
#[derive(DeriveMigrationName)]
9
pub struct Migration;
10

11
#[async_trait::async_trait]
12
impl MigrationTrait for Migration {
13
    async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
65✔
14
        manager
65✔
15
            .create_table(
65✔
16
                Table::create()
65✔
17
                    .table(CategoryTranslations::Table)
65✔
18
                    .if_not_exists()
65✔
19
                    .col(
65✔
20
                        ColumnDef::new(CategoryTranslations::Id)
65✔
21
                            .uuid()
65✔
22
                            .not_null()
65✔
23
                            .primary_key(),
65✔
24
                    )
65✔
25
                    .col(
65✔
26
                        ColumnDef::new(CategoryTranslations::CategoryId)
65✔
27
                            .uuid()
65✔
28
                            .not_null(),
65✔
29
                    )
65✔
30
                    .col(
65✔
31
                        ColumnDef::new(CategoryTranslations::LanguageCode)
65✔
32
                            .string_len(10)
65✔
33
                            .not_null(),
65✔
34
                    )
65✔
35
                    .col(
65✔
36
                        ColumnDef::new(CategoryTranslations::DisplayName)
65✔
37
                            .string_len(NAME_LENGTH)
65✔
38
                            .not_null(),
65✔
39
                    )
65✔
40
                    .col(
65✔
41
                        ColumnDef::new(CategoryTranslations::Slug)
65✔
42
                            .string_len(NAME_LENGTH)
65✔
43
                            .not_null(),
65✔
44
                    )
65✔
45
                    .foreign_key(
65✔
46
                        ForeignKey::create()
65✔
47
                            .name("fk_category_translations_category_id")
65✔
48
                            .from(
65✔
49
                                CategoryTranslations::Table,
65✔
50
                                CategoryTranslations::CategoryId,
65✔
51
                            )
65✔
52
                            .to(Categories::Table, Categories::Id)
65✔
53
                            .on_delete(ForeignKeyAction::Cascade),
65✔
54
                    )
65✔
55
                    .index(
65✔
56
                        Index::create()
65✔
57
                            .name("index_unique_category_translations_slug")
65✔
58
                            .col(CategoryTranslations::Slug)
65✔
59
                            .unique(),
65✔
60
                    )
65✔
61
                    .index(
65✔
62
                        Index::create()
65✔
63
                            .name("index_unique_category_translations_language")
65✔
64
                            .col(CategoryTranslations::CategoryId)
65✔
65
                            .col(CategoryTranslations::LanguageCode)
65✔
66
                            .unique(),
65✔
67
                    )
65✔
68
                    .to_owned(),
65✔
69
            )
65✔
70
            .await?;
65✔
71

72
        manager
65✔
73
            .create_table(
65✔
74
                Table::create()
65✔
75
                    .table(PostTranslations::Table)
65✔
76
                    .if_not_exists()
65✔
77
                    .col(
65✔
78
                        ColumnDef::new(PostTranslations::Id)
65✔
79
                            .uuid()
65✔
80
                            .not_null()
65✔
81
                            .primary_key(),
65✔
82
                    )
65✔
83
                    .col(ColumnDef::new(PostTranslations::PostId).uuid().not_null())
65✔
84
                    .col(
65✔
85
                        ColumnDef::new(PostTranslations::LanguageCode)
65✔
86
                            .string_len(10)
65✔
87
                            .not_null(),
65✔
88
                    )
65✔
89
                    .col(
65✔
90
                        ColumnDef::new(PostTranslations::Title)
65✔
91
                            .string_len(TITLE_LENGTH)
65✔
92
                            .not_null(),
65✔
93
                    )
65✔
94
                    .col(
65✔
95
                        ColumnDef::new(PostTranslations::Slug)
65✔
96
                            .string_len(TITLE_LENGTH)
65✔
97
                            .not_null(),
65✔
98
                    )
65✔
99
                    .col(
65✔
100
                        ColumnDef::new(PostTranslations::PreviewContent)
65✔
101
                            .text()
65✔
102
                            .not_null(),
65✔
103
                    )
65✔
104
                    .col(ColumnDef::new(PostTranslations::Content).text().not_null())
65✔
105
                    .foreign_key(
65✔
106
                        ForeignKey::create()
65✔
107
                            .name("fk_post_translations_post_id")
65✔
108
                            .from(PostTranslations::Table, PostTranslations::PostId)
65✔
109
                            .to(Posts::Table, Posts::Id)
65✔
110
                            .on_delete(ForeignKeyAction::Cascade),
65✔
111
                    )
65✔
112
                    .index(
65✔
113
                        Index::create()
65✔
114
                            .name("index_unique_post_translations_language")
65✔
115
                            .col(PostTranslations::PostId)
65✔
116
                            .col(PostTranslations::LanguageCode)
65✔
117
                            .unique(),
65✔
118
                    )
65✔
119
                    .to_owned(),
65✔
120
            )
65✔
121
            .await?;
65✔
122

123
        Ok(())
65✔
124
    }
130✔
125

NEW
126
    async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
×
NEW
127
        manager
×
NEW
128
            .drop_table(Table::drop().table(CategoryTranslations::Table).to_owned())
×
NEW
129
            .await?;
×
130

NEW
131
        manager
×
NEW
132
            .drop_table(Table::drop().table(PostTranslations::Table).to_owned())
×
NEW
133
            .await?;
×
134

NEW
135
        Ok(())
×
NEW
136
    }
×
137
}
138

139
#[derive(DeriveIden)]
650✔
140
pub enum CategoryTranslations {
141
    Table,
142
    Id,
143
    CategoryId,
144
    LanguageCode,
145
    DisplayName,
146
    Slug,
147
}
148

149
#[derive(DeriveIden)]
715✔
150
pub enum PostTranslations {
151
    Table,
152
    Id,
153
    PostId,
154
    LanguageCode,
155
    Title,
156
    Slug,
157
    PreviewContent,
158
    Content,
159
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc