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

View file

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

View file

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

View file

@ -60,7 +60,7 @@ export class MiMeta {
public maintainerEmail: string | null; public maintainerEmail: string | null;
@Column('boolean', { @Column('boolean', {
default: false, default: true,
}) })
public disableRegistration: boolean; public disableRegistration: boolean;
@ -431,7 +431,7 @@ export class MiMeta {
@Column('varchar', { @Column('varchar', {
length: 1024, length: 1024,
default: 'https://activitypub.software/TransFem-org/Sharkey/', default: 'https://activitypub.software/TransFem-org/Sharkey/',
nullable: false, nullable: true,
}) })
public repositoryUrl: string | null; public repositoryUrl: string | null;
@ -618,8 +618,8 @@ export class MiMeta {
}) })
public enableAchievements: boolean; public enableAchievements: boolean;
@Column('varchar', { @Column('text', {
length: 2048, nullable: true, nullable: true,
}) })
public robotsTxt: string | null; public robotsTxt: string | null;
@ -649,7 +649,7 @@ export class MiMeta {
public bannedEmailDomains: string[]; public bannedEmailDomains: string[];
@Column('varchar', { @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[]; public preservedUsernames: string[];
@ -664,22 +664,22 @@ export class MiMeta {
public enableFanoutTimelineDbFallback: boolean; public enableFanoutTimelineDbFallback: boolean;
@Column('integer', { @Column('integer', {
default: 300, default: 800,
}) })
public perLocalUserUserTimelineCacheMax: number; public perLocalUserUserTimelineCacheMax: number;
@Column('integer', { @Column('integer', {
default: 100, default: 800,
}) })
public perRemoteUserUserTimelineCacheMax: number; public perRemoteUserUserTimelineCacheMax: number;
@Column('integer', { @Column('integer', {
default: 300, default: 800,
}) })
public perUserHomeTimelineCacheMax: number; public perUserHomeTimelineCacheMax: number;
@Column('integer', { @Column('integer', {
default: 300, default: 800,
}) })
public perUserListTimelineCacheMax: number; public perUserListTimelineCacheMax: number;
@ -695,9 +695,9 @@ export class MiMeta {
@Column('varchar', { @Column('varchar', {
length: 500, length: 500,
nullable: true, default: '❤️',
}) })
public defaultLike: string | null; public defaultLike: string;
@Column('varchar', { @Column('varchar', {
length: 256, array: true, default: '{}', length: 256, array: true, default: '{}',
@ -720,7 +720,7 @@ export class MiMeta {
public urlPreviewMaximumContentLength: number; public urlPreviewMaximumContentLength: number;
@Column('boolean', { @Column('boolean', {
default: true, default: false,
}) })
public urlPreviewRequireContentLength: boolean; public urlPreviewRequireContentLength: boolean;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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