From a717fcc70c3a2063f8958c4f9568986122fefa72 Mon Sep 17 00:00:00 2001 From: Johann150 Date: Mon, 11 Jul 2022 22:17:18 +0200 Subject: [PATCH] remove ads from database --- .../migration/1657570176749-remove-ads.ts | 12 ++++ packages/backend/src/db/postgre.ts | 2 - packages/backend/src/models/entities/ad.ts | 59 ------------------- packages/backend/src/models/index.ts | 2 - 4 files changed, 12 insertions(+), 63 deletions(-) create mode 100644 packages/backend/migration/1657570176749-remove-ads.ts delete mode 100644 packages/backend/src/models/entities/ad.ts diff --git a/packages/backend/migration/1657570176749-remove-ads.ts b/packages/backend/migration/1657570176749-remove-ads.ts new file mode 100644 index 000000000..03a4168aa --- /dev/null +++ b/packages/backend/migration/1657570176749-remove-ads.ts @@ -0,0 +1,12 @@ +export class removeAds1657570176749 { + name = 'removeAds1657570176749' + + async up(queryRunner) { + await queryRunner.query(`DROP TABLE "ad"`); + } + + async down(queryRunner) { + await queryRunner.query(`CREATE TABLE public.ad ("id" character varying(32) NOT NULL, "createdAt" timestamp with time zone NOT NULL, "expiresAt" timestamp with time zone NOT NULL, "place" character varying(32) NOT NULL, "priority" character varying(32) NOT NULL, "url" character varying(1024) NOT NULL, "imageUrl" character varying(1024) NOT NULL, "memo" character varying(8192) NOT NULL, "ratio" integer DEFAULT 1 NOT NULL)`); + } + +} diff --git a/packages/backend/src/db/postgre.ts b/packages/backend/src/db/postgre.ts index f8e483939..95386f724 100644 --- a/packages/backend/src/db/postgre.ts +++ b/packages/backend/src/db/postgre.ts @@ -65,7 +65,6 @@ import { Channel } from '@/models/entities/channel.js'; import { ChannelFollowing } from '@/models/entities/channel-following.js'; import { ChannelNotePining } from '@/models/entities/channel-note-pining.js'; import { RegistryItem } from '@/models/entities/registry-item.js'; -import { Ad } from '@/models/entities/ad.js'; import { PasswordResetRequest } from '@/models/entities/password-reset-request.js'; import { UserPending } from '@/models/entities/user-pending.js'; @@ -168,7 +167,6 @@ export const entities = [ ChannelFollowing, ChannelNotePining, RegistryItem, - Ad, PasswordResetRequest, UserPending, Webhook, diff --git a/packages/backend/src/models/entities/ad.ts b/packages/backend/src/models/entities/ad.ts deleted file mode 100644 index 36b758f20..000000000 --- a/packages/backend/src/models/entities/ad.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { Entity, Index, Column, PrimaryColumn } from 'typeorm'; -import { id } from '../id.js'; - -@Entity() -export class Ad { - @PrimaryColumn(id()) - public id: string; - - @Index() - @Column('timestamp with time zone', { - comment: 'The created date of the Ad.', - }) - public createdAt: Date; - - @Index() - @Column('timestamp with time zone', { - comment: 'The expired date of the Ad.', - }) - public expiresAt: Date; - - @Column('varchar', { - length: 32, nullable: false, - }) - public place: string; - - // 今は使われていないが将来的に活用される可能性はある - @Column('varchar', { - length: 32, nullable: false, - }) - public priority: string; - - @Column('integer', { - default: 1, nullable: false, - }) - public ratio: number; - - @Column('varchar', { - length: 1024, nullable: false, - }) - public url: string; - - @Column('varchar', { - length: 1024, nullable: false, - }) - public imageUrl: string; - - @Column('varchar', { - length: 8192, nullable: false, - }) - public memo: string; - - constructor(data: Partial) { - if (data == null) return; - - for (const [k, v] of Object.entries(data)) { - (this as any)[k] = v; - } - } -} diff --git a/packages/backend/src/models/index.ts b/packages/backend/src/models/index.ts index 577b4044b..1005f8c70 100644 --- a/packages/backend/src/models/index.ts +++ b/packages/backend/src/models/index.ts @@ -59,7 +59,6 @@ import { MutedNote } from './entities/muted-note.js'; import { ChannelFollowing } from './entities/channel-following.js'; import { ChannelNotePining } from './entities/channel-note-pining.js'; import { RegistryItem } from './entities/registry-item.js'; -import { Ad } from './entities/ad.js'; import { PasswordResetRequest } from './entities/password-reset-request.js'; import { UserPending } from './entities/user-pending.js'; import { InstanceRepository } from './repositories/instance.js'; @@ -126,5 +125,4 @@ export const ChannelFollowings = db.getRepository(ChannelFollowing); export const ChannelNotePinings = db.getRepository(ChannelNotePining); export const RegistryItems = db.getRepository(RegistryItem); export const Webhooks = db.getRepository(Webhook); -export const Ads = db.getRepository(Ad); export const PasswordResetRequests = db.getRepository(PasswordResetRequest);