jormungandr-bite/docs/mkv13_restore.patch
2023-05-02 20:36:02 -04:00

127 lines
5.7 KiB
Diff

diff --git a/packages/backend/migration/1680491187535-cleanup.js b/packages/backend/migration/1680491187535-cleanup.js
index 1e609ca06..0e6accf3e 100644
--- a/packages/backend/migration/1680491187535-cleanup.js
+++ b/packages/backend/migration/1680491187535-cleanup.js
@@ -1,10 +1,40 @@
export class cleanup1680491187535 {
- name = 'cleanup1680491187535'
+ name = "cleanup1680491187535";
- async up(queryRunner) {
- await queryRunner.query(`DROP TABLE "antenna_note" `);
- }
+ async up(queryRunner) {
+ await queryRunner.query(`DROP TABLE "antenna_note" `);
+ }
- async down(queryRunner) {
- }
+ async down(queryRunner) {
+ await queryRunner.query(
+ `CREATE TABLE antenna_note ( id character varying(32) NOT NULL, "noteId" character varying(32) NOT NULL, "antennaId" character varying(32) NOT NULL, read boolean DEFAULT false NOT NULL)`,
+ );
+ await queryRunner.query(
+ `COMMENT ON COLUMN antenna_note."noteId" IS 'The note ID.'`,
+ );
+ await queryRunner.query(
+ `COMMENT ON COLUMN antenna_note."antennaId" IS 'The antenna ID.'`,
+ );
+ await queryRunner.query(
+ `ALTER TABLE ONLY antenna_note ADD CONSTRAINT "PK_fb28d94d0989a3872df19fd6ef8" PRIMARY KEY (id)`,
+ );
+ await queryRunner.query(
+ `CREATE INDEX "IDX_0d775946662d2575dfd2068a5f" ON antenna_note USING btree ("antennaId")`,
+ );
+ await queryRunner.query(
+ `CREATE UNIQUE INDEX "IDX_335a0bf3f904406f9ef3dd51c2" ON antenna_note USING btree ("noteId", "antennaId")`,
+ );
+ await queryRunner.query(
+ `CREATE INDEX "IDX_9937ea48d7ae97ffb4f3f063a4" ON antenna_note USING btree (read)`,
+ );
+ await queryRunner.query(
+ `CREATE INDEX "IDX_bd0397be22147e17210940e125" ON antenna_note USING btree ("noteId")`,
+ );
+ await queryRunner.query(
+ `ALTER TABLE ONLY antenna_note ADD CONSTRAINT "FK_0d775946662d2575dfd2068a5f5" FOREIGN KEY ("antennaId") REFERENCES antenna(id) ON DELETE CASCADE`,
+ );
+ await queryRunner.query(
+ `ALTER TABLE ONLY antenna_note ADD CONSTRAINT "FK_bd0397be22147e17210940e125b" FOREIGN KEY ("noteId") REFERENCES note(id) ON DELETE CASCADE`,
+ );
+ }
}
diff --git a/packages/backend/migration/1680582195041-cleanup.js b/packages/backend/migration/1680582195041-cleanup.js
index c587e456a..a91d6ff3c 100644
--- a/packages/backend/migration/1680582195041-cleanup.js
+++ b/packages/backend/migration/1680582195041-cleanup.js
@@ -1,11 +1,64 @@
export class cleanup1680582195041 {
- name = 'cleanup1680582195041'
+ name = "cleanup1680582195041";
- async up(queryRunner) {
- await queryRunner.query(`DROP TABLE "notification" `);
- }
+ async up(queryRunner) {
+ await queryRunner.query(`DROP TABLE "notification"`);
+ }
- async down(queryRunner) {
-
- }
+ async down(queryRunner) {
+ await queryRunner.query(
+ `CREATE TABLE notification ( id character varying(32) NOT NULL, "createdAt" timestamp with time zone NOT NULL, "notifieeId" character varying(32) NOT NULL, "notifierId" character varying(32), "isRead" boolean DEFAULT false NOT NULL, "noteId" character varying(32), reaction character varying(128), choice integer, "followRequestId" character varying(32), type notification_type_enum NOT NULL, "customBody" character varying(2048), "customHeader" character varying(256), "customIcon" character varying(1024), "appAccessTokenId" character varying(32), achievement character varying(128))`,
+ );
+ await queryRunner.query(
+ `COMMENT ON COLUMN notification."createdAt" IS 'The created date of the Notification.'`,
+ );
+ await queryRunner.query(
+ `COMMENT ON COLUMN notification."notifieeId" IS 'The ID of recipient user of the Notification.'`,
+ );
+ await queryRunner.query(
+ `COMMENT ON COLUMN notification."notifierId" IS 'The ID of sender user of the Notification.'`,
+ );
+ await queryRunner.query(
+ `COMMENT ON COLUMN notification."isRead" IS 'Whether the Notification is read.'`,
+ );
+ await queryRunner.query(
+ `COMMENT ON COLUMN notification.type IS 'The type of the Notification.'`,
+ );
+ await queryRunner.query(
+ `ALTER TABLE ONLY notification ADD CONSTRAINT "PK_705b6c7cdf9b2c2ff7ac7872cb7" PRIMARY KEY (id)`,
+ );
+ await queryRunner.query(
+ `CREATE INDEX "IDX_080ab397c379af09b9d2169e5b" ON notification USING btree ("isRead")`,
+ );
+ await queryRunner.query(
+ `CREATE INDEX "IDX_33f33cc8ef29d805a97ff4628b" ON notification USING btree (type)`,
+ );
+ await queryRunner.query(
+ `CREATE INDEX "IDX_3b4e96eec8d36a8bbb9d02aa71" ON notification USING btree ("notifierId")`,
+ );
+ await queryRunner.query(
+ `CREATE INDEX "IDX_3c601b70a1066d2c8b517094cb" ON notification USING btree ("notifieeId")`,
+ );
+ await queryRunner.query(
+ `CREATE INDEX "IDX_b11a5e627c41d4dc3170f1d370" ON notification USING btree ("createdAt")`,
+ );
+ await queryRunner.query(
+ `CREATE INDEX "IDX_e22bf6bda77b6adc1fd9e75c8c" ON notification USING btree ("appAccessTokenId")`,
+ );
+ await queryRunner.query(
+ `ALTER TABLE ONLY notification ADD CONSTRAINT "FK_3b4e96eec8d36a8bbb9d02aa710" FOREIGN KEY ("notifierId") REFERENCES "user"(id) ON DELETE CASCADE`,
+ );
+ await queryRunner.query(
+ `ALTER TABLE ONLY notification ADD CONSTRAINT "FK_3c601b70a1066d2c8b517094cb9" FOREIGN KEY ("notifieeId") REFERENCES "user"(id) ON DELETE CASCADE`,
+ );
+ await queryRunner.query(
+ `ALTER TABLE ONLY notification ADD CONSTRAINT "FK_769cb6b73a1efe22ddf733ac453" FOREIGN KEY ("noteId") REFERENCES note(id) ON DELETE CASCADE`,
+ );
+ await queryRunner.query(
+ `ALTER TABLE ONLY notification ADD CONSTRAINT "FK_bd7fab507621e635b32cd31892c" FOREIGN KEY ("followRequestId") REFERENCES follow_request(id) ON DELETE CASCADE`,
+ );
+ await queryRunner.query(
+ `ALTER TABLE ONLY notification ADD CONSTRAINT "FK_e22bf6bda77b6adc1fd9e75c8c9" FOREIGN KEY ("appAccessTokenId") REFERENCES access_token(id) ON DELETE CASCADE`,
+ );
+ }
}