Removed the page tables

This commit is contained in:
Natty 2024-01-12 23:13:00 +01:00
parent 789852211b
commit 13f5ad3672
Signed by: natty
GPG Key ID: BF6CB659ADEE60EC
8 changed files with 120 additions and 58 deletions

View File

@ -65,8 +65,6 @@ pub enum Relation {
on_delete = "SetNull"
)]
DriveFolder,
#[sea_orm(has_many = "super::page::Entity")]
Page,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
@ -83,12 +81,6 @@ impl Related<super::drive_folder::Entity> for Entity {
}
}
impl Related<super::page::Entity> for Entity {
fn to() -> RelationDef {
Relation::Page.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()

View File

@ -36,8 +36,6 @@ pub mod note_thread_muting;
pub mod note_unread;
pub mod note_watching;
pub mod notification;
pub mod page;
pub mod page_like;
pub mod password_reset_request;
pub mod poll;
pub mod poll_vote;

View File

@ -34,8 +34,6 @@ pub use super::note_thread_muting::Entity as NoteThreadMuting;
pub use super::note_unread::Entity as NoteUnread;
pub use super::note_watching::Entity as NoteWatching;
pub use super::notification::Entity as Notification;
pub use super::page::Entity as Page;
pub use super::page_like::Entity as PageLike;
pub use super::password_reset_request::Entity as PasswordResetRequest;
pub use super::poll::Entity as Poll;
pub use super::poll_vote::Entity as PollVote;

View File

@ -118,20 +118,6 @@ pub enum NotificationTypeEnum {
Reply,
}
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Copy, Serialize, Deserialize)]
#[sea_orm(
rs_type = "String",
db_type = "Enum",
enum_name = "page_visibility_enum"
)]
pub enum PageVisibilityEnum {
#[sea_orm(string_value = "followers")]
Followers,
#[sea_orm(string_value = "public")]
Public,
#[sea_orm(string_value = "specified")]
Specified,
}
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum, Copy, Serialize, Deserialize)]
#[sea_orm(
rs_type = "String",
db_type = "Enum",

View File

@ -128,10 +128,6 @@ pub enum Relation {
NoteUnread,
#[sea_orm(has_many = "super::note_watching::Entity")]
NoteWatching,
#[sea_orm(has_many = "super::page::Entity")]
Page,
#[sea_orm(has_many = "super::page_like::Entity")]
PageLike,
#[sea_orm(has_many = "super::password_reset_request::Entity")]
PasswordResetRequest,
#[sea_orm(has_many = "super::poll_vote::Entity")]
@ -276,18 +272,6 @@ impl Related<super::note_watching::Entity> for Entity {
}
}
impl Related<super::page::Entity> for Entity {
fn to() -> RelationDef {
Relation::Page.def()
}
}
impl Related<super::page_like::Entity> for Entity {
fn to() -> RelationDef {
Relation::PageLike.def()
}
}
impl Related<super::password_reset_request::Entity> for Entity {
fn to() -> RelationDef {
Relation::PasswordResetRequest.def()

View File

@ -42,8 +42,6 @@ pub struct Model {
pub security_keys_available: bool,
#[sea_orm(column_name = "usePasswordLessLogin")]
pub use_password_less_login: bool,
#[sea_orm(column_name = "pinnedPageId", unique)]
pub pinned_page_id: Option<String>,
#[sea_orm(column_type = "JsonBinary")]
pub room: Json,
#[sea_orm(column_type = "JsonBinary")]
@ -77,14 +75,6 @@ pub struct Model {
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "super::page::Entity",
from = "Column::PinnedPageId",
to = "super::page::Column::Id",
on_update = "NoAction",
on_delete = "SetNull"
)]
Page,
#[sea_orm(
belongs_to = "super::user::Entity",
from = "Column::UserId",
@ -95,12 +85,6 @@ pub enum Relation {
User,
}
impl Related<super::page::Entity> for Entity {
fn to() -> RelationDef {
Relation::Page.def()
}
}
impl Related<super::user::Entity> for Entity {
fn to() -> RelationDef {
Relation::User.def()

View File

@ -7,6 +7,7 @@ mod m20230806_142918_drop_featured_note_option;
mod m20240107_005747_remove_user_groups;
mod m20240107_220523_generated_is_quote;
mod m20240107_224446_generated_is_renote;
mod m20240112_215106_remove_pages;
pub struct Migrator;
@ -21,6 +22,7 @@ impl MigratorTrait for Migrator {
Box::new(m20240107_005747_remove_user_groups::Migration),
Box::new(m20240107_220523_generated_is_quote::Migration),
Box::new(m20240107_224446_generated_is_renote::Migration),
Box::new(m20240112_215106_remove_pages::Migration),
]
}
}

View File

@ -0,0 +1,118 @@
use sea_orm_migration::prelude::*;
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
let db = manager.get_connection();
db.execute_unprepared(
r#"
ALTER TABLE "user_profile" DROP COLUMN "pinnedPageId";
DROP TABLE "page_like";
DROP TABLE "page";
"#,
)
.await?;
Ok(())
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
let db = manager.get_connection();
db.execute_unprepared(
r#"
create table page
(
id varchar(32) not null
constraint "PK_742f4117e065c5b6ad21b37ba1f"
primary key,
"createdAt" timestamp with time zone not null,
"updatedAt" timestamp with time zone not null,
title varchar(256) not null,
name varchar(256) not null,
summary varchar(256),
"alignCenter" boolean not null,
font varchar(32) not null,
"userId" varchar(32) not null
constraint "FK_ae1d917992dd0c9d9bbdad06c4a"
references "user"
on delete cascade,
"eyeCatchingImageId" varchar(32)
constraint "FK_a9ca79ad939bf06066b81c9d3aa"
references drive_file
on delete cascade,
content jsonb default '[]'::jsonb not null,
variables jsonb default '[]'::jsonb not null,
visibility page_visibility_enum not null,
"visibleUserIds" varchar(32)[] default '{}'::character varying[] not null,
"likedCount" integer default 0 not null,
"hideTitleWhenPinned" boolean default false not null,
script varchar(16384) default ''::character varying not null,
"isPublic" boolean default true not null
);
comment on column page."createdAt" is 'The created date of the Page.';
comment on column page."updatedAt" is 'The updated date of the Page.';
comment on column page."userId" is 'The ID of author.';
create index "IDX_fbb4297c927a9b85e9cefa2eb1"
on page ("createdAt");
create index "IDX_af639b066dfbca78b01a920f8a"
on page ("updatedAt");
create index "IDX_b82c19c08afb292de4600d99e4"
on page (name);
create index "IDX_ae1d917992dd0c9d9bbdad06c4"
on page ("userId");
create index "IDX_90148bbc2bf0854428786bfc15"
on page ("visibleUserIds");
create unique index "IDX_2133ef8317e4bdb839c0dcbf13"
on page ("userId", name);
create table page_like
(
id varchar(32) not null
constraint "PK_813f034843af992d3ae0f43c64c"
primary key,
"createdAt" timestamp with time zone not null,
"userId" varchar(32) not null
constraint "FK_0e61efab7f88dbb79c9166dbb48"
references "user"
on delete cascade,
"pageId" varchar(32) not null
constraint "FK_cf8782626dced3176038176a847"
references page
on delete cascade
);
create index "IDX_0e61efab7f88dbb79c9166dbb4"
on page_like ("userId");
create unique index "IDX_4ce6fb9c70529b4c8ac46c9bfa"
on page_like ("userId", "pageId");
alter table user_profile
add "pinnedPageId" varchar(32)
constraint "UQ_6dc44f1ceb65b1e72bacef2ca27"
unique
constraint "FK_6dc44f1ceb65b1e72bacef2ca27"
references page
on delete set null;
"#,
)
.await?;
Ok(())
}
}