merge: Synchronize database entities and code models (!1040)

View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/1040

Approved-by: dakkar <dakkar@thenautilus.net>
Approved-by: Marie <github@yuugi.dev>
This commit is contained in:
Marie 2025-05-23 23:33:08 +00:00
commit e59a3ad693
21 changed files with 214 additions and 25 deletions

View file

@ -0,0 +1,16 @@
/*
* SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
export class RenameFollowingVisibility1747934911491 {
name = 'RenameFollowingVisibility1747934911491'
async up(queryRunner) {
await queryRunner.query(`ALTER TYPE "public"."user_profile_followingvisibility_enum" RENAME TO "user_profile_followingVisibility_enum"`);
}
async down(queryRunner) {
await queryRunner.query(`ALTER TYPE "public"."user_profile_followingVisibility_enum" RENAME TO "user_profile_followingvisibility_enum"`);
}
}

View file

@ -0,0 +1,30 @@
/*
* SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
export class AddEntityComments1747935197708 {
name = 'AddEntityComments1747935197708'
async up(queryRunner) {
await queryRunner.query(`COMMENT ON COLUMN "user"."backgroundId" IS 'The ID of background DriveFile.'`);
await queryRunner.query(`COMMENT ON COLUMN "user"."isSilenced" IS 'Whether the User is silenced.'`);
await queryRunner.query(`COMMENT ON COLUMN "user"."noindex" IS 'Whether the User''s notes dont get indexed.'`);
await queryRunner.query(`COMMENT ON COLUMN "user"."speakAsCat" IS 'Whether the User speaks in nya.'`);
await queryRunner.query(`COMMENT ON COLUMN "user_profile"."listenbrainz" IS 'The ListenBrainz username of the User.'`);
await queryRunner.query(`COMMENT ON COLUMN "note"."updatedAt" IS 'The update time of the Note.'`);
await queryRunner.query(`COMMENT ON COLUMN "meta"."trustedLinkUrlPatterns" IS 'An array of URL strings or regex that can be used to omit warnings about redirects to external sites. Separate them with spaces to specify AND, and enclose them with slashes to specify regular expressions. Each item is regarded as an OR.'`);
await queryRunner.query(`COMMENT ON COLUMN "note_edit"."oldDate" IS 'The old date from before the edit'`);
}
async down(queryRunner) {
await queryRunner.query(`COMMENT ON COLUMN "note_edit"."oldDate" IS NULL`);
await queryRunner.query(`COMMENT ON COLUMN "meta"."trustedLinkUrlPatterns" IS NULL`);
await queryRunner.query(`COMMENT ON COLUMN "note"."updatedAt" IS 'The updated date of the Note.'`);
await queryRunner.query(`COMMENT ON COLUMN "user_profile"."listenbrainz" IS 'listenbrainz username to fetch currently playing.'`);
await queryRunner.query(`COMMENT ON COLUMN "user"."speakAsCat" IS 'Whether to speak as a cat if chosen.'`);
await queryRunner.query(`COMMENT ON COLUMN "user"."noindex" IS NULL`);
await queryRunner.query(`COMMENT ON COLUMN "user"."isSilenced" IS NULL`);
await queryRunner.query(`COMMENT ON COLUMN "user"."backgroundId" IS NULL`);
}
}

View file

@ -0,0 +1,16 @@
/*
* SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
export class FixSystemWebhookUpdatedAtDefault1747937504140 {
name = 'FixSystemWebhookUpdatedAtDefault1747937504140'
async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "system_webhook" ALTER COLUMN "updatedAt" SET DEFAULT now()`);
}
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "system_webhook" ALTER COLUMN "updatedAt" SET DEFAULT CURRENT_TIMESTAMP`);
}
}

View file

@ -0,0 +1,16 @@
/*
* SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
export class FixAbuseReportNotificationRecipientUpdatedAtDefault1747937670341 {
name = 'FixAbuseReportNotificationRecipientUpdatedAtDefault1747937670341'
async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "abuse_report_notification_recipient" ALTER COLUMN "updatedAt" SET DEFAULT now()`);
}
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "abuse_report_notification_recipient" ALTER COLUMN "updatedAt" SET DEFAULT CURRENT_TIMESTAMP`);
}
}

View file

@ -0,0 +1,16 @@
/*
* SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
export class FixFlashVisibilityNullable1747937796573 {
name = 'FixFlashVisibilityNullable1747937796573'
async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "flash" ALTER COLUMN "visibility" SET NOT NULL`);
}
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "flash" ALTER COLUMN "visibility" DROP NOT NULL`);
}
}

View file

@ -0,0 +1,18 @@
/*
* SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
export class FixAbuseReportNotificationRecipientDefaults1747938136399 {
name = 'FixAbuseReportNotificationRecipientDefaults1747938136399'
async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "abuse_report_notification_recipient" ALTER COLUMN "userId" DROP DEFAULT`);
await queryRunner.query(`ALTER TABLE "abuse_report_notification_recipient" ALTER COLUMN "systemWebhookId" DROP DEFAULT`);
}
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "abuse_report_notification_recipient" ALTER COLUMN "systemWebhookId" SET DEFAULT NULL`);
await queryRunner.query(`ALTER TABLE "abuse_report_notification_recipient" ALTER COLUMN "userId" SET DEFAULT NULL`);
}
}

View file

@ -0,0 +1,16 @@
/*
* SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
export class FixMetaUrlPreviewUserAgentDefault1747938263980 {
name = 'FixMetaUrlPreviewUserAgentDefault1747938263980'
async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" ALTER COLUMN "urlPreviewUserAgent" DROP DEFAULT`);
}
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" ALTER COLUMN "urlPreviewUserAgent" SET DEFAULT NULL`);
}
}

View file

@ -0,0 +1,22 @@
/*
* SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
export class AddMissingIndexes1747938628395 {
name = 'AddMissingIndexes1747938628395'
async up(queryRunner) {
await queryRunner.query(`CREATE INDEX "IDX_58699f75b9cf904f5f007909cb" ON "user_profile" ("birthday") `);
await queryRunner.query(`CREATE INDEX "IDX_021015e6683570ae9f6b0c62be" ON "user_list_membership" ("userId") `);
await queryRunner.query(`CREATE INDEX "IDX_cddcaf418dc4d392ecfcca842a" ON "user_list_membership" ("userListId") `);
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_e4f3094c43f2d665e6030b0337" ON "user_list_membership" ("userId", "userListId") `);
}
async down(queryRunner) {
await queryRunner.query(`DROP INDEX "public"."IDX_e4f3094c43f2d665e6030b0337"`);
await queryRunner.query(`DROP INDEX "public"."IDX_cddcaf418dc4d392ecfcca842a"`);
await queryRunner.query(`DROP INDEX "public"."IDX_021015e6683570ae9f6b0c62be"`);
await queryRunner.query(`DROP INDEX "public"."IDX_58699f75b9cf904f5f007909cb"`);
}
}

View file

@ -0,0 +1,16 @@
/*
* SPDX-FileCopyrightText: hazelnoot and other Sharkey contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
export class AlterMetaDefaultLikeNotNull1747944466178 {
name = 'AlterMetaDefaultLikeNotNull1747944466178'
async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" ALTER COLUMN "defaultLike" SET NOT NULL`);
}
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "meta" ALTER COLUMN "defaultLike" DROP NOT NULL`);
}
}

View file

@ -22,7 +22,7 @@ export class MiAbuseReportNotificationRecipient {
/**
* .
*/
@Index()
@Index('IDX_abuse_report_notification_recipient_isActive')
@Column('boolean', {
default: true,
})
@ -47,7 +47,7 @@ export class MiAbuseReportNotificationRecipient {
/**
* .
*/
@Index()
@Index('IDX_abuse_report_notification_recipient_method')
@Column('varchar', {
length: 64,
})
@ -56,7 +56,7 @@ export class MiAbuseReportNotificationRecipient {
/**
* ID.
*/
@Index()
@Index('IDX_abuse_report_notification_recipient_userId')
@Column({
...id(),
nullable: true,
@ -75,14 +75,16 @@ export class MiAbuseReportNotificationRecipient {
/**
* .
*/
@ManyToOne(type => MiUserProfile, {})
@ManyToOne(type => MiUserProfile, {
onDelete: 'CASCADE',
})
@JoinColumn({ name: 'userId', referencedColumnName: 'userId', foreignKeyConstraintName: 'FK_abuse_report_notification_recipient_userId2' })
public userProfile: MiUserProfile | null;
/**
* WebhookId.
*/
@Index()
@Index('IDX_abuse_report_notification_recipient_systemWebhookId')
@Column({
...id(),
nullable: true,
@ -95,6 +97,8 @@ export class MiAbuseReportNotificationRecipient {
@ManyToOne(type => MiSystemWebhook, {
onDelete: 'CASCADE',
})
@JoinColumn()
@JoinColumn({
foreignKeyConstraintName: 'FK_abuse_report_notification_recipient_systemWebhookId',
})
public systemWebhook: MiSystemWebhook | null;
}

View file

@ -29,6 +29,7 @@ export class MiEmoji {
})
public host: string | null;
@Index('IDX_EMOJI_CATEGORY')
@Column('varchar', {
length: 128, nullable: true,
})
@ -77,6 +78,8 @@ export class MiEmoji {
public isSensitive: boolean;
// TODO: 定期ジョブで存在しなくなったロールIDを除去するようにする
// Synchronize: false is needed because TypeORM doesn't understand GIN indexes
@Index('IDX_EMOJI_ROLE_IDS', { synchronize: false })
@Column('varchar', {
array: true, length: 128, default: '{}',
})

View file

@ -45,6 +45,7 @@ export class SkLatestNote {
})
@JoinColumn({
name: 'user_id',
foreignKeyConstraintName: 'FK_20e346fffe4a2174585005d6d80',
})
public user: MiUser | null;
@ -60,6 +61,7 @@ export class SkLatestNote {
})
@JoinColumn({
name: 'note_id',
foreignKeyConstraintName: 'FK_47a38b1c13de6ce4e5090fb1acd',
})
public note: MiNote | null;

View file

@ -60,7 +60,7 @@ export class MiMeta {
public maintainerEmail: string | null;
@Column('boolean', {
default: false,
default: true,
})
public disableRegistration: boolean;
@ -431,7 +431,7 @@ export class MiMeta {
@Column('varchar', {
length: 1024,
default: 'https://activitypub.software/TransFem-org/Sharkey/',
nullable: false,
nullable: true,
})
public repositoryUrl: string | null;
@ -618,8 +618,8 @@ export class MiMeta {
})
public enableAchievements: boolean;
@Column('varchar', {
length: 2048, nullable: true,
@Column('text', {
nullable: true,
})
public robotsTxt: string | null;
@ -649,7 +649,7 @@ export class MiMeta {
public bannedEmailDomains: string[];
@Column('varchar', {
length: 1024, array: true, default: '{ "admin", "administrator", "root", "system", "maintainer", "host", "mod", "moderator", "owner", "superuser", "staff", "auth", "i", "me", "everyone", "all", "mention", "mentions", "example", "user", "users", "account", "accounts", "official", "help", "helps", "support", "supports", "info", "information", "informations", "announce", "announces", "announcement", "announcements", "notice", "notification", "notifications", "dev", "developer", "developers", "tech", "misskey" }',
length: 1024, array: true, default: '{admin,administrator,root,system,maintainer,host,mod,moderator,owner,superuser,staff,auth,i,me,everyone,all,mention,mentions,example,user,users,account,accounts,official,help,helps,support,supports,info,information,informations,announce,announces,announcement,announcements,notice,notification,notifications,dev,developer,developers,tech,misskey}',
})
public preservedUsernames: string[];
@ -664,22 +664,22 @@ export class MiMeta {
public enableFanoutTimelineDbFallback: boolean;
@Column('integer', {
default: 300,
default: 800,
})
public perLocalUserUserTimelineCacheMax: number;
@Column('integer', {
default: 100,
default: 800,
})
public perRemoteUserUserTimelineCacheMax: number;
@Column('integer', {
default: 300,
default: 800,
})
public perUserHomeTimelineCacheMax: number;
@Column('integer', {
default: 300,
default: 800,
})
public perUserListTimelineCacheMax: number;
@ -695,9 +695,9 @@ export class MiMeta {
@Column('varchar', {
length: 500,
nullable: true,
default: '❤️',
})
public defaultLike: string | null;
public defaultLike: string;
@Column('varchar', {
length: 256, array: true, default: '{}',
@ -720,7 +720,7 @@ export class MiMeta {
public urlPreviewMaximumContentLength: number;
@Column('boolean', {
default: true,
default: false,
})
public urlPreviewRequireContentLength: boolean;

View file

@ -10,7 +10,7 @@ import { MiUser } from './User.js';
import { MiChannel } from './Channel.js';
import type { MiDriveFile } from './DriveFile.js';
@Index(['userId', 'id'])
@Index('IDX_724b311e6f883751f261ebe378', ['userId', 'id'])
@Entity('note')
export class MiNote {
@PrimaryColumn(id())

View file

@ -129,7 +129,9 @@ export class MiUser {
@OneToOne(() => MiDriveFile, {
onDelete: 'SET NULL',
})
@JoinColumn()
@JoinColumn({
foreignKeyConstraintName: 'FK_q5lm0tbgejtfskzg0rc4wd7t1n',
})
public background: MiDriveFile | null;
// avatarId が null になったとしてもこれが null でない可能性があるため、このフィールドを使うときは avatarId の non-null チェックをすること
@ -345,7 +347,7 @@ export class MiUser {
*/
@Column('boolean', {
name: 'enable_rss',
default: true,
default: false,
})
public enableRss: boolean;

View file

@ -24,7 +24,9 @@ export class MiUserListMembership {
@ManyToOne(type => MiUser, {
onDelete: 'CASCADE',
})
@JoinColumn()
@JoinColumn({
foreignKeyConstraintName: 'FK_d844bfc6f3f523a05189076efaa',
})
public user: MiUser | null;
@Index()
@ -37,7 +39,9 @@ export class MiUserListMembership {
@ManyToOne(type => MiUserList, {
onDelete: 'CASCADE',
})
@JoinColumn()
@JoinColumn({
foreignKeyConstraintName: 'FK_605472305f26818cc93d1baaa74',
})
public userList: MiUserList | null;
// タイムラインにその人のリプライまで含めるかどうか

View file

@ -34,6 +34,7 @@ export class MiUserPending {
@Column('varchar', {
length: 1000,
nullable: true,
})
public reason: string;
}

View file

@ -110,12 +110,14 @@ export class MiUserProfile {
@Column('enum', {
enum: followingVisibilities,
enumName: 'user_profile_followingVisibility_enum',
default: 'public',
})
public followingVisibility: typeof followingVisibilities[number];
@Column('enum', {
enum: followersVisibilities,
enumName: 'user_profile_followersVisibility_enum',
default: 'public',
})
public followersVisibility: typeof followersVisibilities[number];

View file

@ -481,6 +481,10 @@ export const meta = {
type: 'string',
optional: false, nullable: true,
},
defaultLike: {
type: 'string',
optional: false, nullable: false,
},
description: {
type: 'string',
optional: false, nullable: true,

View file

@ -69,7 +69,7 @@ export const paramDef = {
description: { type: 'string', nullable: true },
defaultLightTheme: { type: 'string', nullable: true },
defaultDarkTheme: { type: 'string', nullable: true },
defaultLike: { type: 'string', nullable: true },
defaultLike: { type: 'string' },
cacheRemoteFiles: { type: 'boolean' },
cacheRemoteSensitiveFiles: { type: 'boolean' },
emailRequiredForSignup: { type: 'boolean' },

View file

@ -9259,6 +9259,7 @@ export type operations = {
libreTranslateKey: string | null;
defaultDarkTheme: string | null;
defaultLightTheme: string | null;
defaultLike: string;
description: string | null;
disableRegistration: boolean;
impressumUrl: string | null;
@ -12137,7 +12138,7 @@ export type operations = {
description?: string | null;
defaultLightTheme?: string | null;
defaultDarkTheme?: string | null;
defaultLike?: string | null;
defaultLike?: string;
cacheRemoteFiles?: boolean;
cacheRemoteSensitiveFiles?: boolean;
emailRequiredForSignup?: boolean;