Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc1fd58a

Browse files
committed
refactor(annim): use jsonb for extra
1 parentbfff0b2 commitc1fd58a

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-1
lines changed

‎annim/src/entities/postgres/album.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub struct Model {
2020
publevel:MetadataOrganizeLevel,
2121
pubcreated_at:DateTime,
2222
pubupdated_at:DateTime,
23+
#[sea_orm(column_type ="JsonBinary", nullable)]
2324
pubextra:Option<Json>,
2425
}
2526

‎annim/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ async fn graphql_ws_handler(
6060
#[tokio::main]
6161
asyncfnmain() -> anyhow::Result<()>{
6262
tracing_subscriber::fmt()
63-
.with_max_level(tracing::Level::WARN)
63+
.with_max_level(tracing::Level::INFO)
6464
.with_test_writer()
6565
.init();
6666

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
use sea_orm::DbErr;
2+
use sea_orm_migration::{prelude::*, schema::*};
3+
4+
usesuper::m20240817_000001_create_basic_tables::Album;
5+
6+
pubstructMigration;
7+
8+
implMigrationNameforMigration{
9+
fnname(&self) ->&str{
10+
"m20240905_000004_album_extra_jsonb"
11+
}
12+
}
13+
14+
#[async_trait::async_trait]
15+
implMigrationTraitforMigration{
16+
asyncfnup(&self,manager:&SchemaManager) ->Result<(),DbErr>{
17+
manager
18+
.alter_table(
19+
Table::alter()
20+
.table(Album::Table)
21+
.modify_column(json_binary_null(Album::Extra))
22+
.to_owned(),
23+
)
24+
.await?;
25+
26+
Ok(())
27+
}
28+
29+
asyncfndown(&self,manager:&SchemaManager) ->Result<(),DbErr>{
30+
manager
31+
.alter_table(
32+
Table::alter()
33+
.modify_column(json_null(Album::Extra))
34+
.to_owned(),
35+
)
36+
.await?;
37+
38+
Ok(())
39+
}
40+
}

‎annim/src/migrator/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ mod helper;
44
mod m20240817_000001_create_basic_tables;
55
mod m20240824_000002_create_tag_tables;
66
mod m20240905_000003_add_tag_type_category;
7+
mod m20240905_000004_album_extra_jsonb;
78

89
pubstructMigrator;
910

@@ -14,6 +15,7 @@ impl MigratorTrait for Migrator {
1415
Box::new(m20240817_000001_create_basic_tables::Migration),
1516
Box::new(m20240824_000002_create_tag_tables::Migration),
1617
Box::new(m20240905_000003_add_tag_type_category::Migration),
18+
Box::new(m20240905_000004_album_extra_jsonb::Migration),
1719
]
1820
}
1921
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp