Skip to content

Commit

Permalink
chore: update deezer_id to string
Browse files Browse the repository at this point in the history
  • Loading branch information
metehus committed Dec 19, 2023
1 parent 6447e64 commit 814b30c
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 7 deletions.
8 changes: 8 additions & 0 deletions prisma/migrations/20231219015919_deezer_id_str/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- AlterTable
ALTER TABLE "Album" ADD COLUMN "deezer_id_str" TEXT;

-- AlterTable
ALTER TABLE "Artist" ADD COLUMN "deezer_id_str" TEXT;

-- AlterTable
ALTER TABLE "Track" ADD COLUMN "deezer_id_str" TEXT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- copy deezer_id to deezer_id_str and cast
UPDATE "Artist"
SET "deezer_id_str" = "deezer_id"::text;

UPDATE "Album"
SET "deezer_id_str" = "deezer_id"::text;

UPDATE "Track"
SET "deezer_id_str" = "deezer_id"::text;
8 changes: 8 additions & 0 deletions prisma/migrations/20231219021123_move_deezer_id/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- AlterTable
ALTER TABLE "Album" ALTER COLUMN "deezer_id" SET DATA TYPE TEXT;

-- AlterTable
ALTER TABLE "Artist" ALTER COLUMN "deezer_id" SET DATA TYPE TEXT;

-- AlterTable
ALTER TABLE "Track" ALTER COLUMN "deezer_id" SET DATA TYPE TEXT;
16 changes: 16 additions & 0 deletions prisma/migrations/20231219021404_drop_deezer_id_str/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
Warnings:
- You are about to drop the column `deezer_id_str` on the `Album` table. All the data in the column will be lost.
- You are about to drop the column `deezer_id_str` on the `Artist` table. All the data in the column will be lost.
- You are about to drop the column `deezer_id_str` on the `Track` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "Album" DROP COLUMN "deezer_id_str";

-- AlterTable
ALTER TABLE "Artist" DROP COLUMN "deezer_id_str";

-- AlterTable
ALTER TABLE "Track" DROP COLUMN "deezer_id_str";
6 changes: 3 additions & 3 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ model Artist {
similar String[] @db.Text
spotify_id String? @db.Char(22)
deezer_id BigInt? @db.BigInt
deezer_id String? @db.Text
created_at DateTime @default(now())
updated_at DateTime?
Expand All @@ -92,7 +92,7 @@ model Album {
tags String[] @db.Text
spotify_id String? @db.Char(22)
deezer_id BigInt? @db.BigInt
deezer_id String? @db.Text
release_date String? @db.VarChar(16)
created_at DateTime @default(now())
Expand Down Expand Up @@ -120,7 +120,7 @@ model Track {
album String? @db.Text
spotify_id String? @db.Char(22)
deezer_id BigInt? @db.BigInt
deezer_id String? @db.Text
genius_id Int?
tags String[] @db.Text
Expand Down
2 changes: 1 addition & 1 deletion src/finders/album.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ export function formatDisplayAlbum ({
hash,
name,
spotify_id: spotify_id,
deezer_id: deezer_id,
deezer_id: deezer_id ? parseInt(deezer_id) : null,
artists: artists,
tags: tags,
release_date: release_date,
Expand Down
2 changes: 1 addition & 1 deletion src/finders/artist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ export function formatDisplayArtist ({
hash,
name,
spotify_id: spotify_id,
deezer_id: deezer_id,
deezer_id: deezer_id ? parseInt(deezer_id) : null,
genres: genres,
similar: similar,
tags: tags,
Expand Down
4 changes: 2 additions & 2 deletions src/finders/track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ async function findTrackFromDeezer (
const selected = data
.find(a => normalizeString(a.title) === normalizeString(item.name)) || data[0]

item.deezer_id = selected.id
item.deezer_id = selected.id.toString()
item.preview = selected.preview
item.explicit = item.explicit ? true : selected.explicit_lyrics
item.album = item.album ?? selected.album.title
Expand Down Expand Up @@ -383,7 +383,7 @@ export function formatDisplayTrack ({
album,
artists,
spotify_id,
deezer_id,
deezer_id: deezer_id ? parseInt(deezer_id) : null,
genius_id,
tags,
duration,
Expand Down

0 comments on commit 814b30c

Please sign in to comment.