-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store feed response bodies in postgres instead of redis
- Loading branch information
Showing
12 changed files
with
132 additions
and
35 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
services/feed-requests/migrations/Migration20250102112346.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Migration } from '@mikro-orm/migrations'; | ||
|
||
export class Migration20250102112346 extends Migration { | ||
|
||
async up(): Promise<void> { | ||
// create table response_bodies with auto increment id, text column "body" and hash_key column "hash_key" | ||
this.addSql('CREATE TABLE "response_bodies" ("content" TEXT NOT NULL, "hash_key" TEXT NOT NULL);'); | ||
// create index on hash_key column | ||
this.addSql('CREATE UNIQUE INDEX "response_bodies_hash_key" ON "response_bodies" ("hash_key");'); | ||
|
||
// add column response_body_hash_key to request_partitioned | ||
this.addSql('ALTER TABLE "request_partitioned" ADD COLUMN "response_body_hash_key" TEXT DEFAULT NULL NULL;'); | ||
// add foreign key constraint to response_body_hash_key column | ||
this.addSql(`ALTER TABLE "request_partitioned" ADD CONSTRAINT "request_partitioned_response_body_hash_key_fk" FOREIGN KEY ("response_body_hash_key") REFERENCES "response_bodies" ("hash_key") ON DELETE SET NULL;`); | ||
} | ||
|
||
async down(): Promise<void> { | ||
// drop table response_bodies | ||
this.addSql('DROP TABLE "response_bodies";'); | ||
// drop column response_body_hash_key from request_partitioned | ||
this.addSql('ALTER TABLE "request_partitioned" DROP COLUMN "response_body_hash_key";'); | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
services/feed-requests/migrations/Migration20250102220055.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Migration } from '@mikro-orm/migrations'; | ||
|
||
export class Migration20250102220055 extends Migration { | ||
|
||
async up(): Promise<void> { | ||
// add column content_hash to response_bodies | ||
this.addSql('ALTER TABLE "response_bodies" ADD COLUMN "content_hash" TEXT DEFAULT NULL NULL;'); | ||
} | ||
|
||
async down(): Promise<void> { | ||
// drop column content_hash from response_bodies | ||
this.addSql('ALTER TABLE "response_bodies" DROP COLUMN "content_hash";'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
services/user-feeds/src/articles/exceptions/invalid-feed.exception.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
export class InvalidFeedException extends Error {} | ||
export class InvalidFeedException extends Error { | ||
constructor(message: string, public feedText: string) { | ||
super(message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters