Skip to content

Commit

Permalink
Add a new migration to clean up notification tables before creating n…
Browse files Browse the repository at this point in the history
…ew tables
  • Loading branch information
PooyaRaki committed Nov 7, 2024
1 parent fd2a068 commit 037b635
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
35 changes: 35 additions & 0 deletions migrations/1726452966034-notification_cleanup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { MigrationInterface, QueryRunner } from 'typeorm';

export class NotificationCleanup1726452966034 implements MigrationInterface {
name = 'NotificationCleanup1726452966034';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`DROP TRIGGER IF EXISTS "update_push_notification_devices_updated_at" ON "push_notification_devices"`,
);
await queryRunner.query(
`DROP TRIGGER IF EXISTS "update_notification_subscriptions_updated_at" ON "notification_subscriptions"`,
);
await queryRunner.query(
`DROP TYPE IF EXISTS "notification_types_name_enum" CASCADE`,
);
await queryRunner.query(
`DROP TYPE IF EXISTS "push_notification_devices_device_type_enum" CASCADE`,
);
await queryRunner.query(`DROP FUNCTION IF EXISTS update_updated_at()`);
await queryRunner.query(
`DROP TABLE IF EXISTS "push_notification_devices" CASCADE`,
);
await queryRunner.query(
`DROP TABLE IF EXISTS "notification_subscriptions" CASCADE`,
);
await queryRunner.query(
`DROP TABLE IF EXISTS "notification_subscription_notification_types" CASCADE`,
);
await queryRunner.query(
`DROP TABLE IF EXISTS "notification_types" CASCADE`,
);
}

public async down(): Promise<void> {}
}
2 changes: 1 addition & 1 deletion migrations/1727451367471-notifications_enum.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import type { MigrationInterface, QueryRunner } from 'typeorm';

export class NotificationsEnum1727451367471 implements MigrationInterface {
name = 'NotificationsEnum1727451367471';
Expand Down
2 changes: 1 addition & 1 deletion migrations/1727701600427-update_timestamp_trigger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import type { MigrationInterface, QueryRunner } from 'typeorm';

export class UpdateTimestampTrigger1727701600427 implements MigrationInterface {
name = 'UpdateTimestampTrigger1727701600427';
Expand Down
2 changes: 1 addition & 1 deletion migrations/1727701873513-notification_update_updated_at.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import type { MigrationInterface, QueryRunner } from 'typeorm';

export class NotificationUpdateUpdatedAt1727701873513
implements MigrationInterface
Expand Down

0 comments on commit 037b635

Please sign in to comment.