Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 16 additions & 11 deletions src/database/migrations/1748119392860-CreateReleaseTable.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import { MigrationInterface, QueryRunner } from "typeorm";
import { MigrationInterface, QueryRunner } from 'typeorm';

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

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TABLE "releases" ("id" SERIAL NOT NULL, "discogs_id" integer NOT NULL, "title" character varying NOT NULL, "year" integer, "thumb_url" character varying, "cover_image_url" character varying, "artists" json NOT NULL, "labels" json, "formats" json, "genres" json, "styles" json, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "updated_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "UQ_c0b05a1fcbfcc0b5310dec3e400" UNIQUE ("discogs_id"), CONSTRAINT "PK_6b6fc2599a5a281dd44a7d64016" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE INDEX "IDX_c0b05a1fcbfcc0b5310dec3e40" ON "releases" ("discogs_id") `);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP INDEX "public"."IDX_c0b05a1fcbfcc0b5310dec3e40"`);
await queryRunner.query(`DROP TABLE "releases"`);
}
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TABLE "releases" ("id" SERIAL NOT NULL, "discogs_id" integer NOT NULL, "title" character varying NOT NULL, "year" integer, "thumb_url" character varying, "cover_image_url" character varying, "artists" json NOT NULL, "labels" json, "formats" json, "genres" json, "styles" json, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "updated_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "UQ_c0b05a1fcbfcc0b5310dec3e400" UNIQUE ("discogs_id"), CONSTRAINT "PK_6b6fc2599a5a281dd44a7d64016" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`CREATE INDEX "IDX_c0b05a1fcbfcc0b5310dec3e40" ON "releases" ("discogs_id") `,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`DROP INDEX "public"."IDX_c0b05a1fcbfcc0b5310dec3e40"`,
);
await queryRunner.query(`DROP TABLE "releases"`);
}
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,57 @@
import { MigrationInterface, QueryRunner } from "typeorm";
import { MigrationInterface, QueryRunner } from 'typeorm';

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

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TABLE "user_collections" ("id" SERIAL NOT NULL, "user_id" character varying NOT NULL, "release_id" integer NOT NULL, "discogs_instance_id" integer, "folder_id" integer NOT NULL DEFAULT '0', "rating" smallint NOT NULL DEFAULT '0', "notes" text, "customFields" json, "date_added" TIMESTAMP, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "updated_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_0f50c79662214ef4d0f14956980" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE INDEX "IDX_64c12326d36a9ead157b3757d4" ON "user_collections" ("user_id") `);
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_a62fffd30546ee94fb9cf557da" ON "user_collections" ("user_id", "release_id") `);
await queryRunner.query(`CREATE TABLE "user_wantlists" ("id" SERIAL NOT NULL, "user_id" character varying NOT NULL, "release_id" integer NOT NULL, "notes" text, "date_added" TIMESTAMP, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "updated_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_ed19af2fe54473eec7a9bbb48b0" PRIMARY KEY ("id"))`);
await queryRunner.query(`CREATE INDEX "IDX_f1f891440bf3768ac812ed92ab" ON "user_wantlists" ("user_id") `);
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_e5bbdf79a43fa87f67849ce292" ON "user_wantlists" ("user_id", "release_id") `);
await queryRunner.query(`ALTER TABLE "user_collections" ADD CONSTRAINT "FK_8b43f7ada150082e862a3a0e1a4" FOREIGN KEY ("release_id") REFERENCES "releases"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "user_wantlists" ADD CONSTRAINT "FK_ff0cb82493c8a0bf603d446c05f" FOREIGN KEY ("release_id") REFERENCES "releases"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "user_wantlists" DROP CONSTRAINT "FK_ff0cb82493c8a0bf603d446c05f"`);
await queryRunner.query(`ALTER TABLE "user_collections" DROP CONSTRAINT "FK_8b43f7ada150082e862a3a0e1a4"`);
await queryRunner.query(`DROP INDEX "public"."IDX_e5bbdf79a43fa87f67849ce292"`);
await queryRunner.query(`DROP INDEX "public"."IDX_f1f891440bf3768ac812ed92ab"`);
await queryRunner.query(`DROP TABLE "user_wantlists"`);
await queryRunner.query(`DROP INDEX "public"."IDX_a62fffd30546ee94fb9cf557da"`);
await queryRunner.query(`DROP INDEX "public"."IDX_64c12326d36a9ead157b3757d4"`);
await queryRunner.query(`DROP TABLE "user_collections"`);
}
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TABLE "user_collections" ("id" SERIAL NOT NULL, "user_id" character varying NOT NULL, "release_id" integer NOT NULL, "discogs_instance_id" integer, "folder_id" integer NOT NULL DEFAULT '0', "rating" smallint NOT NULL DEFAULT '0', "notes" text, "customFields" json, "date_added" TIMESTAMP, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "updated_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_0f50c79662214ef4d0f14956980" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`CREATE INDEX "IDX_64c12326d36a9ead157b3757d4" ON "user_collections" ("user_id") `,
);
await queryRunner.query(
`CREATE UNIQUE INDEX "IDX_a62fffd30546ee94fb9cf557da" ON "user_collections" ("user_id", "release_id") `,
);
await queryRunner.query(
`CREATE TABLE "user_wantlists" ("id" SERIAL NOT NULL, "user_id" character varying NOT NULL, "release_id" integer NOT NULL, "notes" text, "date_added" TIMESTAMP, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "updated_at" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_ed19af2fe54473eec7a9bbb48b0" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`CREATE INDEX "IDX_f1f891440bf3768ac812ed92ab" ON "user_wantlists" ("user_id") `,
);
await queryRunner.query(
`CREATE UNIQUE INDEX "IDX_e5bbdf79a43fa87f67849ce292" ON "user_wantlists" ("user_id", "release_id") `,
);
await queryRunner.query(
`ALTER TABLE "user_collections" ADD CONSTRAINT "FK_8b43f7ada150082e862a3a0e1a4" FOREIGN KEY ("release_id") REFERENCES "releases"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
);
await queryRunner.query(
`ALTER TABLE "user_wantlists" ADD CONSTRAINT "FK_ff0cb82493c8a0bf603d446c05f" FOREIGN KEY ("release_id") REFERENCES "releases"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "user_wantlists" DROP CONSTRAINT "FK_ff0cb82493c8a0bf603d446c05f"`,
);
await queryRunner.query(
`ALTER TABLE "user_collections" DROP CONSTRAINT "FK_8b43f7ada150082e862a3a0e1a4"`,
);
await queryRunner.query(
`DROP INDEX "public"."IDX_e5bbdf79a43fa87f67849ce292"`,
);
await queryRunner.query(
`DROP INDEX "public"."IDX_f1f891440bf3768ac812ed92ab"`,
);
await queryRunner.query(`DROP TABLE "user_wantlists"`);
await queryRunner.query(
`DROP INDEX "public"."IDX_a62fffd30546ee94fb9cf557da"`,
);
await queryRunner.query(
`DROP INDEX "public"."IDX_64c12326d36a9ead157b3757d4"`,
);
await queryRunner.query(`DROP TABLE "user_collections"`);
}
}
Loading