A decentralized music tracking and discovery platform built on AT Protocol 🎵

Add composite index to tracks

Create idx_title_artist_album_albumartist on tracks (title, artist,
album, album_artist) and update the Drizzle schema, migration snapshot,
and journal

+1617 -32
+1
apps/cli/drizzle/0001_awesome_gabe_jones.sql
··· 1 + CREATE INDEX `idx_title_artist_album_albumartist` ON `tracks` (`title`,`artist`,`album`,`album_artist`);
+1569
apps/cli/drizzle/meta/0001_snapshot.json
··· 1 + { 2 + "version": "6", 3 + "dialect": "sqlite", 4 + "id": "a927ee38-ce82-46d0-9494-e75c29248159", 5 + "prevId": "926f883e-c7c5-4c01-b88b-c8f7f649559a", 6 + "tables": { 7 + "album_tracks": { 8 + "name": "album_tracks", 9 + "columns": { 10 + "id": { 11 + "name": "id", 12 + "type": "text", 13 + "primaryKey": true, 14 + "notNull": true, 15 + "autoincrement": false 16 + }, 17 + "album_id": { 18 + "name": "album_id", 19 + "type": "text", 20 + "primaryKey": false, 21 + "notNull": true, 22 + "autoincrement": false 23 + }, 24 + "track_id": { 25 + "name": "track_id", 26 + "type": "text", 27 + "primaryKey": false, 28 + "notNull": true, 29 + "autoincrement": false 30 + }, 31 + "created_at": { 32 + "name": "created_at", 33 + "type": "integer", 34 + "primaryKey": false, 35 + "notNull": true, 36 + "autoincrement": false, 37 + "default": "(unixepoch())" 38 + }, 39 + "updated_at": { 40 + "name": "updated_at", 41 + "type": "integer", 42 + "primaryKey": false, 43 + "notNull": true, 44 + "autoincrement": false, 45 + "default": "(unixepoch())" 46 + } 47 + }, 48 + "indexes": { 49 + "album_tracks_unique_index": { 50 + "name": "album_tracks_unique_index", 51 + "columns": [ 52 + "album_id", 53 + "track_id" 54 + ], 55 + "isUnique": true 56 + } 57 + }, 58 + "foreignKeys": { 59 + "album_tracks_album_id_albums_id_fk": { 60 + "name": "album_tracks_album_id_albums_id_fk", 61 + "tableFrom": "album_tracks", 62 + "tableTo": "albums", 63 + "columnsFrom": [ 64 + "album_id" 65 + ], 66 + "columnsTo": [ 67 + "id" 68 + ], 69 + "onDelete": "no action", 70 + "onUpdate": "no action" 71 + }, 72 + "album_tracks_track_id_tracks_id_fk": { 73 + "name": "album_tracks_track_id_tracks_id_fk", 74 + "tableFrom": "album_tracks", 75 + "tableTo": "tracks", 76 + "columnsFrom": [ 77 + "track_id" 78 + ], 79 + "columnsTo": [ 80 + "id" 81 + ], 82 + "onDelete": "no action", 83 + "onUpdate": "no action" 84 + } 85 + }, 86 + "compositePrimaryKeys": {}, 87 + "uniqueConstraints": {}, 88 + "checkConstraints": {} 89 + }, 90 + "albums": { 91 + "name": "albums", 92 + "columns": { 93 + "id": { 94 + "name": "id", 95 + "type": "text", 96 + "primaryKey": true, 97 + "notNull": true, 98 + "autoincrement": false 99 + }, 100 + "title": { 101 + "name": "title", 102 + "type": "text", 103 + "primaryKey": false, 104 + "notNull": true, 105 + "autoincrement": false 106 + }, 107 + "artist": { 108 + "name": "artist", 109 + "type": "text", 110 + "primaryKey": false, 111 + "notNull": true, 112 + "autoincrement": false 113 + }, 114 + "release_date": { 115 + "name": "release_date", 116 + "type": "text", 117 + "primaryKey": false, 118 + "notNull": false, 119 + "autoincrement": false 120 + }, 121 + "year": { 122 + "name": "year", 123 + "type": "integer", 124 + "primaryKey": false, 125 + "notNull": false, 126 + "autoincrement": false 127 + }, 128 + "album_art": { 129 + "name": "album_art", 130 + "type": "text", 131 + "primaryKey": false, 132 + "notNull": false, 133 + "autoincrement": false 134 + }, 135 + "uri": { 136 + "name": "uri", 137 + "type": "text", 138 + "primaryKey": false, 139 + "notNull": false, 140 + "autoincrement": false 141 + }, 142 + "cid": { 143 + "name": "cid", 144 + "type": "text", 145 + "primaryKey": false, 146 + "notNull": true, 147 + "autoincrement": false 148 + }, 149 + "artist_uri": { 150 + "name": "artist_uri", 151 + "type": "text", 152 + "primaryKey": false, 153 + "notNull": false, 154 + "autoincrement": false 155 + }, 156 + "apple_music_link": { 157 + "name": "apple_music_link", 158 + "type": "text", 159 + "primaryKey": false, 160 + "notNull": false, 161 + "autoincrement": false 162 + }, 163 + "spotify_link": { 164 + "name": "spotify_link", 165 + "type": "text", 166 + "primaryKey": false, 167 + "notNull": false, 168 + "autoincrement": false 169 + }, 170 + "tidal_link": { 171 + "name": "tidal_link", 172 + "type": "text", 173 + "primaryKey": false, 174 + "notNull": false, 175 + "autoincrement": false 176 + }, 177 + "youtube_link": { 178 + "name": "youtube_link", 179 + "type": "text", 180 + "primaryKey": false, 181 + "notNull": false, 182 + "autoincrement": false 183 + }, 184 + "created_at": { 185 + "name": "created_at", 186 + "type": "integer", 187 + "primaryKey": false, 188 + "notNull": true, 189 + "autoincrement": false, 190 + "default": "(unixepoch())" 191 + }, 192 + "updated_at": { 193 + "name": "updated_at", 194 + "type": "integer", 195 + "primaryKey": false, 196 + "notNull": true, 197 + "autoincrement": false, 198 + "default": "(unixepoch())" 199 + } 200 + }, 201 + "indexes": { 202 + "albums_uri_unique": { 203 + "name": "albums_uri_unique", 204 + "columns": [ 205 + "uri" 206 + ], 207 + "isUnique": true 208 + }, 209 + "albums_cid_unique": { 210 + "name": "albums_cid_unique", 211 + "columns": [ 212 + "cid" 213 + ], 214 + "isUnique": true 215 + }, 216 + "albums_apple_music_link_unique": { 217 + "name": "albums_apple_music_link_unique", 218 + "columns": [ 219 + "apple_music_link" 220 + ], 221 + "isUnique": true 222 + }, 223 + "albums_spotify_link_unique": { 224 + "name": "albums_spotify_link_unique", 225 + "columns": [ 226 + "spotify_link" 227 + ], 228 + "isUnique": true 229 + }, 230 + "albums_tidal_link_unique": { 231 + "name": "albums_tidal_link_unique", 232 + "columns": [ 233 + "tidal_link" 234 + ], 235 + "isUnique": true 236 + }, 237 + "albums_youtube_link_unique": { 238 + "name": "albums_youtube_link_unique", 239 + "columns": [ 240 + "youtube_link" 241 + ], 242 + "isUnique": true 243 + } 244 + }, 245 + "foreignKeys": {}, 246 + "compositePrimaryKeys": {}, 247 + "uniqueConstraints": {}, 248 + "checkConstraints": {} 249 + }, 250 + "artist_albums": { 251 + "name": "artist_albums", 252 + "columns": { 253 + "id": { 254 + "name": "id", 255 + "type": "text", 256 + "primaryKey": true, 257 + "notNull": true, 258 + "autoincrement": false 259 + }, 260 + "artist_id": { 261 + "name": "artist_id", 262 + "type": "text", 263 + "primaryKey": false, 264 + "notNull": true, 265 + "autoincrement": false 266 + }, 267 + "album_id": { 268 + "name": "album_id", 269 + "type": "text", 270 + "primaryKey": false, 271 + "notNull": true, 272 + "autoincrement": false 273 + }, 274 + "created_at": { 275 + "name": "created_at", 276 + "type": "integer", 277 + "primaryKey": false, 278 + "notNull": true, 279 + "autoincrement": false, 280 + "default": "(unixepoch())" 281 + }, 282 + "updated_at": { 283 + "name": "updated_at", 284 + "type": "integer", 285 + "primaryKey": false, 286 + "notNull": true, 287 + "autoincrement": false, 288 + "default": "(unixepoch())" 289 + } 290 + }, 291 + "indexes": { 292 + "artist_albums_unique_index": { 293 + "name": "artist_albums_unique_index", 294 + "columns": [ 295 + "artist_id", 296 + "album_id" 297 + ], 298 + "isUnique": true 299 + } 300 + }, 301 + "foreignKeys": { 302 + "artist_albums_artist_id_artists_id_fk": { 303 + "name": "artist_albums_artist_id_artists_id_fk", 304 + "tableFrom": "artist_albums", 305 + "tableTo": "artists", 306 + "columnsFrom": [ 307 + "artist_id" 308 + ], 309 + "columnsTo": [ 310 + "id" 311 + ], 312 + "onDelete": "no action", 313 + "onUpdate": "no action" 314 + }, 315 + "artist_albums_album_id_albums_id_fk": { 316 + "name": "artist_albums_album_id_albums_id_fk", 317 + "tableFrom": "artist_albums", 318 + "tableTo": "albums", 319 + "columnsFrom": [ 320 + "album_id" 321 + ], 322 + "columnsTo": [ 323 + "id" 324 + ], 325 + "onDelete": "no action", 326 + "onUpdate": "no action" 327 + } 328 + }, 329 + "compositePrimaryKeys": {}, 330 + "uniqueConstraints": {}, 331 + "checkConstraints": {} 332 + }, 333 + "artist_genres ": { 334 + "name": "artist_genres ", 335 + "columns": { 336 + "id": { 337 + "name": "id", 338 + "type": "text", 339 + "primaryKey": true, 340 + "notNull": true, 341 + "autoincrement": false 342 + }, 343 + "artist_id": { 344 + "name": "artist_id", 345 + "type": "text", 346 + "primaryKey": false, 347 + "notNull": true, 348 + "autoincrement": false 349 + }, 350 + "genre_id": { 351 + "name": "genre_id", 352 + "type": "text", 353 + "primaryKey": false, 354 + "notNull": true, 355 + "autoincrement": false 356 + } 357 + }, 358 + "indexes": { 359 + "artist_genre_unique_index": { 360 + "name": "artist_genre_unique_index", 361 + "columns": [ 362 + "artist_id", 363 + "genre_id" 364 + ], 365 + "isUnique": true 366 + } 367 + }, 368 + "foreignKeys": {}, 369 + "compositePrimaryKeys": {}, 370 + "uniqueConstraints": {}, 371 + "checkConstraints": {} 372 + }, 373 + "artist_tracks": { 374 + "name": "artist_tracks", 375 + "columns": { 376 + "id": { 377 + "name": "id", 378 + "type": "text", 379 + "primaryKey": true, 380 + "notNull": true, 381 + "autoincrement": false 382 + }, 383 + "artist_id": { 384 + "name": "artist_id", 385 + "type": "text", 386 + "primaryKey": false, 387 + "notNull": true, 388 + "autoincrement": false 389 + }, 390 + "track_id": { 391 + "name": "track_id", 392 + "type": "text", 393 + "primaryKey": false, 394 + "notNull": true, 395 + "autoincrement": false 396 + }, 397 + "created_at": { 398 + "name": "created_at", 399 + "type": "integer", 400 + "primaryKey": false, 401 + "notNull": true, 402 + "autoincrement": false, 403 + "default": "(unixepoch())" 404 + }, 405 + "updated_at": { 406 + "name": "updated_at", 407 + "type": "integer", 408 + "primaryKey": false, 409 + "notNull": true, 410 + "autoincrement": false, 411 + "default": "(unixepoch())" 412 + } 413 + }, 414 + "indexes": { 415 + "artist_tracks_unique_index": { 416 + "name": "artist_tracks_unique_index", 417 + "columns": [ 418 + "artist_id", 419 + "track_id" 420 + ], 421 + "isUnique": true 422 + } 423 + }, 424 + "foreignKeys": { 425 + "artist_tracks_artist_id_artists_id_fk": { 426 + "name": "artist_tracks_artist_id_artists_id_fk", 427 + "tableFrom": "artist_tracks", 428 + "tableTo": "artists", 429 + "columnsFrom": [ 430 + "artist_id" 431 + ], 432 + "columnsTo": [ 433 + "id" 434 + ], 435 + "onDelete": "no action", 436 + "onUpdate": "no action" 437 + }, 438 + "artist_tracks_track_id_tracks_id_fk": { 439 + "name": "artist_tracks_track_id_tracks_id_fk", 440 + "tableFrom": "artist_tracks", 441 + "tableTo": "tracks", 442 + "columnsFrom": [ 443 + "track_id" 444 + ], 445 + "columnsTo": [ 446 + "id" 447 + ], 448 + "onDelete": "no action", 449 + "onUpdate": "no action" 450 + } 451 + }, 452 + "compositePrimaryKeys": {}, 453 + "uniqueConstraints": {}, 454 + "checkConstraints": {} 455 + }, 456 + "artists": { 457 + "name": "artists", 458 + "columns": { 459 + "id": { 460 + "name": "id", 461 + "type": "text", 462 + "primaryKey": true, 463 + "notNull": true, 464 + "autoincrement": false 465 + }, 466 + "name": { 467 + "name": "name", 468 + "type": "text", 469 + "primaryKey": false, 470 + "notNull": true, 471 + "autoincrement": false 472 + }, 473 + "biography": { 474 + "name": "biography", 475 + "type": "text", 476 + "primaryKey": false, 477 + "notNull": false, 478 + "autoincrement": false 479 + }, 480 + "born": { 481 + "name": "born", 482 + "type": "integer", 483 + "primaryKey": false, 484 + "notNull": false, 485 + "autoincrement": false 486 + }, 487 + "born_in": { 488 + "name": "born_in", 489 + "type": "text", 490 + "primaryKey": false, 491 + "notNull": false, 492 + "autoincrement": false 493 + }, 494 + "died": { 495 + "name": "died", 496 + "type": "integer", 497 + "primaryKey": false, 498 + "notNull": false, 499 + "autoincrement": false 500 + }, 501 + "picture": { 502 + "name": "picture", 503 + "type": "text", 504 + "primaryKey": false, 505 + "notNull": false, 506 + "autoincrement": false 507 + }, 508 + "uri": { 509 + "name": "uri", 510 + "type": "text", 511 + "primaryKey": false, 512 + "notNull": false, 513 + "autoincrement": false 514 + }, 515 + "cid": { 516 + "name": "cid", 517 + "type": "text", 518 + "primaryKey": false, 519 + "notNull": true, 520 + "autoincrement": false 521 + }, 522 + "apple_music_link": { 523 + "name": "apple_music_link", 524 + "type": "text", 525 + "primaryKey": false, 526 + "notNull": false, 527 + "autoincrement": false 528 + }, 529 + "spotify_link": { 530 + "name": "spotify_link", 531 + "type": "text", 532 + "primaryKey": false, 533 + "notNull": false, 534 + "autoincrement": false 535 + }, 536 + "tidal_link": { 537 + "name": "tidal_link", 538 + "type": "text", 539 + "primaryKey": false, 540 + "notNull": false, 541 + "autoincrement": false 542 + }, 543 + "youtube_link": { 544 + "name": "youtube_link", 545 + "type": "text", 546 + "primaryKey": false, 547 + "notNull": false, 548 + "autoincrement": false 549 + }, 550 + "genres": { 551 + "name": "genres", 552 + "type": "text", 553 + "primaryKey": false, 554 + "notNull": false, 555 + "autoincrement": false 556 + }, 557 + "created_at": { 558 + "name": "created_at", 559 + "type": "integer", 560 + "primaryKey": false, 561 + "notNull": true, 562 + "autoincrement": false, 563 + "default": "(unixepoch())" 564 + }, 565 + "updated_at": { 566 + "name": "updated_at", 567 + "type": "integer", 568 + "primaryKey": false, 569 + "notNull": true, 570 + "autoincrement": false, 571 + "default": "(unixepoch())" 572 + } 573 + }, 574 + "indexes": { 575 + "artists_uri_unique": { 576 + "name": "artists_uri_unique", 577 + "columns": [ 578 + "uri" 579 + ], 580 + "isUnique": true 581 + }, 582 + "artists_cid_unique": { 583 + "name": "artists_cid_unique", 584 + "columns": [ 585 + "cid" 586 + ], 587 + "isUnique": true 588 + } 589 + }, 590 + "foreignKeys": {}, 591 + "compositePrimaryKeys": {}, 592 + "uniqueConstraints": {}, 593 + "checkConstraints": {} 594 + }, 595 + "auth_sessions": { 596 + "name": "auth_sessions", 597 + "columns": { 598 + "key": { 599 + "name": "key", 600 + "type": "text", 601 + "primaryKey": true, 602 + "notNull": true, 603 + "autoincrement": false 604 + }, 605 + "session": { 606 + "name": "session", 607 + "type": "text", 608 + "primaryKey": false, 609 + "notNull": true, 610 + "autoincrement": false 611 + }, 612 + "created_at": { 613 + "name": "created_at", 614 + "type": "integer", 615 + "primaryKey": false, 616 + "notNull": true, 617 + "autoincrement": false, 618 + "default": "(unixepoch())" 619 + }, 620 + "updated_at": { 621 + "name": "updated_at", 622 + "type": "integer", 623 + "primaryKey": false, 624 + "notNull": true, 625 + "autoincrement": false, 626 + "default": "(unixepoch())" 627 + } 628 + }, 629 + "indexes": {}, 630 + "foreignKeys": {}, 631 + "compositePrimaryKeys": {}, 632 + "uniqueConstraints": {}, 633 + "checkConstraints": {} 634 + }, 635 + "genres": { 636 + "name": "genres", 637 + "columns": { 638 + "id": { 639 + "name": "id", 640 + "type": "text", 641 + "primaryKey": true, 642 + "notNull": true, 643 + "autoincrement": false 644 + }, 645 + "name": { 646 + "name": "name", 647 + "type": "text", 648 + "primaryKey": false, 649 + "notNull": true, 650 + "autoincrement": false 651 + }, 652 + "created_at": { 653 + "name": "created_at", 654 + "type": "integer", 655 + "primaryKey": false, 656 + "notNull": true, 657 + "autoincrement": false, 658 + "default": "(unixepoch())" 659 + }, 660 + "updated_at": { 661 + "name": "updated_at", 662 + "type": "integer", 663 + "primaryKey": false, 664 + "notNull": true, 665 + "autoincrement": false, 666 + "default": "(unixepoch())" 667 + } 668 + }, 669 + "indexes": { 670 + "genres_name_unique": { 671 + "name": "genres_name_unique", 672 + "columns": [ 673 + "name" 674 + ], 675 + "isUnique": true 676 + } 677 + }, 678 + "foreignKeys": {}, 679 + "compositePrimaryKeys": {}, 680 + "uniqueConstraints": {}, 681 + "checkConstraints": {} 682 + }, 683 + "loved_tracks": { 684 + "name": "loved_tracks", 685 + "columns": { 686 + "id": { 687 + "name": "id", 688 + "type": "text", 689 + "primaryKey": true, 690 + "notNull": true, 691 + "autoincrement": false 692 + }, 693 + "user_id": { 694 + "name": "user_id", 695 + "type": "text", 696 + "primaryKey": false, 697 + "notNull": true, 698 + "autoincrement": false 699 + }, 700 + "track_id": { 701 + "name": "track_id", 702 + "type": "text", 703 + "primaryKey": false, 704 + "notNull": true, 705 + "autoincrement": false 706 + }, 707 + "uri": { 708 + "name": "uri", 709 + "type": "text", 710 + "primaryKey": false, 711 + "notNull": false, 712 + "autoincrement": false 713 + }, 714 + "created_at": { 715 + "name": "created_at", 716 + "type": "integer", 717 + "primaryKey": false, 718 + "notNull": true, 719 + "autoincrement": false, 720 + "default": "(unixepoch())" 721 + } 722 + }, 723 + "indexes": { 724 + "loved_tracks_uri_unique": { 725 + "name": "loved_tracks_uri_unique", 726 + "columns": [ 727 + "uri" 728 + ], 729 + "isUnique": true 730 + }, 731 + "loved_tracks_unique_index": { 732 + "name": "loved_tracks_unique_index", 733 + "columns": [ 734 + "user_id", 735 + "track_id" 736 + ], 737 + "isUnique": true 738 + } 739 + }, 740 + "foreignKeys": { 741 + "loved_tracks_user_id_users_id_fk": { 742 + "name": "loved_tracks_user_id_users_id_fk", 743 + "tableFrom": "loved_tracks", 744 + "tableTo": "users", 745 + "columnsFrom": [ 746 + "user_id" 747 + ], 748 + "columnsTo": [ 749 + "id" 750 + ], 751 + "onDelete": "no action", 752 + "onUpdate": "no action" 753 + }, 754 + "loved_tracks_track_id_tracks_id_fk": { 755 + "name": "loved_tracks_track_id_tracks_id_fk", 756 + "tableFrom": "loved_tracks", 757 + "tableTo": "tracks", 758 + "columnsFrom": [ 759 + "track_id" 760 + ], 761 + "columnsTo": [ 762 + "id" 763 + ], 764 + "onDelete": "no action", 765 + "onUpdate": "no action" 766 + } 767 + }, 768 + "compositePrimaryKeys": {}, 769 + "uniqueConstraints": {}, 770 + "checkConstraints": {} 771 + }, 772 + "scrobbles": { 773 + "name": "scrobbles", 774 + "columns": { 775 + "xata_id": { 776 + "name": "xata_id", 777 + "type": "text", 778 + "primaryKey": true, 779 + "notNull": true, 780 + "autoincrement": false 781 + }, 782 + "user_id": { 783 + "name": "user_id", 784 + "type": "text", 785 + "primaryKey": false, 786 + "notNull": false, 787 + "autoincrement": false 788 + }, 789 + "track_id": { 790 + "name": "track_id", 791 + "type": "text", 792 + "primaryKey": false, 793 + "notNull": false, 794 + "autoincrement": false 795 + }, 796 + "album_id": { 797 + "name": "album_id", 798 + "type": "text", 799 + "primaryKey": false, 800 + "notNull": false, 801 + "autoincrement": false 802 + }, 803 + "artist_id": { 804 + "name": "artist_id", 805 + "type": "text", 806 + "primaryKey": false, 807 + "notNull": false, 808 + "autoincrement": false 809 + }, 810 + "uri": { 811 + "name": "uri", 812 + "type": "text", 813 + "primaryKey": false, 814 + "notNull": false, 815 + "autoincrement": false 816 + }, 817 + "cid": { 818 + "name": "cid", 819 + "type": "text", 820 + "primaryKey": false, 821 + "notNull": false, 822 + "autoincrement": false 823 + }, 824 + "created_at": { 825 + "name": "created_at", 826 + "type": "integer", 827 + "primaryKey": false, 828 + "notNull": true, 829 + "autoincrement": false, 830 + "default": "(unixepoch())" 831 + }, 832 + "updated_at": { 833 + "name": "updated_at", 834 + "type": "integer", 835 + "primaryKey": false, 836 + "notNull": true, 837 + "autoincrement": false, 838 + "default": "(unixepoch())" 839 + }, 840 + "timestamp": { 841 + "name": "timestamp", 842 + "type": "integer", 843 + "primaryKey": false, 844 + "notNull": true, 845 + "autoincrement": false, 846 + "default": "(unixepoch())" 847 + } 848 + }, 849 + "indexes": { 850 + "scrobbles_uri_unique": { 851 + "name": "scrobbles_uri_unique", 852 + "columns": [ 853 + "uri" 854 + ], 855 + "isUnique": true 856 + }, 857 + "scrobbles_cid_unique": { 858 + "name": "scrobbles_cid_unique", 859 + "columns": [ 860 + "cid" 861 + ], 862 + "isUnique": true 863 + } 864 + }, 865 + "foreignKeys": { 866 + "scrobbles_user_id_users_id_fk": { 867 + "name": "scrobbles_user_id_users_id_fk", 868 + "tableFrom": "scrobbles", 869 + "tableTo": "users", 870 + "columnsFrom": [ 871 + "user_id" 872 + ], 873 + "columnsTo": [ 874 + "id" 875 + ], 876 + "onDelete": "no action", 877 + "onUpdate": "no action" 878 + }, 879 + "scrobbles_track_id_tracks_id_fk": { 880 + "name": "scrobbles_track_id_tracks_id_fk", 881 + "tableFrom": "scrobbles", 882 + "tableTo": "tracks", 883 + "columnsFrom": [ 884 + "track_id" 885 + ], 886 + "columnsTo": [ 887 + "id" 888 + ], 889 + "onDelete": "no action", 890 + "onUpdate": "no action" 891 + }, 892 + "scrobbles_album_id_albums_id_fk": { 893 + "name": "scrobbles_album_id_albums_id_fk", 894 + "tableFrom": "scrobbles", 895 + "tableTo": "albums", 896 + "columnsFrom": [ 897 + "album_id" 898 + ], 899 + "columnsTo": [ 900 + "id" 901 + ], 902 + "onDelete": "no action", 903 + "onUpdate": "no action" 904 + }, 905 + "scrobbles_artist_id_artists_id_fk": { 906 + "name": "scrobbles_artist_id_artists_id_fk", 907 + "tableFrom": "scrobbles", 908 + "tableTo": "artists", 909 + "columnsFrom": [ 910 + "artist_id" 911 + ], 912 + "columnsTo": [ 913 + "id" 914 + ], 915 + "onDelete": "no action", 916 + "onUpdate": "no action" 917 + } 918 + }, 919 + "compositePrimaryKeys": {}, 920 + "uniqueConstraints": {}, 921 + "checkConstraints": {} 922 + }, 923 + "tracks": { 924 + "name": "tracks", 925 + "columns": { 926 + "id": { 927 + "name": "id", 928 + "type": "text", 929 + "primaryKey": true, 930 + "notNull": true, 931 + "autoincrement": false 932 + }, 933 + "title": { 934 + "name": "title", 935 + "type": "text", 936 + "primaryKey": false, 937 + "notNull": true, 938 + "autoincrement": false 939 + }, 940 + "artist": { 941 + "name": "artist", 942 + "type": "text", 943 + "primaryKey": false, 944 + "notNull": true, 945 + "autoincrement": false 946 + }, 947 + "album_artist": { 948 + "name": "album_artist", 949 + "type": "text", 950 + "primaryKey": false, 951 + "notNull": true, 952 + "autoincrement": false 953 + }, 954 + "album_art": { 955 + "name": "album_art", 956 + "type": "text", 957 + "primaryKey": false, 958 + "notNull": false, 959 + "autoincrement": false 960 + }, 961 + "album": { 962 + "name": "album", 963 + "type": "text", 964 + "primaryKey": false, 965 + "notNull": true, 966 + "autoincrement": false 967 + }, 968 + "track_number": { 969 + "name": "track_number", 970 + "type": "integer", 971 + "primaryKey": false, 972 + "notNull": false, 973 + "autoincrement": false 974 + }, 975 + "duration": { 976 + "name": "duration", 977 + "type": "integer", 978 + "primaryKey": false, 979 + "notNull": true, 980 + "autoincrement": false 981 + }, 982 + "mb_id": { 983 + "name": "mb_id", 984 + "type": "text", 985 + "primaryKey": false, 986 + "notNull": false, 987 + "autoincrement": false 988 + }, 989 + "youtube_link": { 990 + "name": "youtube_link", 991 + "type": "text", 992 + "primaryKey": false, 993 + "notNull": false, 994 + "autoincrement": false 995 + }, 996 + "spotify_link": { 997 + "name": "spotify_link", 998 + "type": "text", 999 + "primaryKey": false, 1000 + "notNull": false, 1001 + "autoincrement": false 1002 + }, 1003 + "apple_music_link": { 1004 + "name": "apple_music_link", 1005 + "type": "text", 1006 + "primaryKey": false, 1007 + "notNull": false, 1008 + "autoincrement": false 1009 + }, 1010 + "tidal_link": { 1011 + "name": "tidal_link", 1012 + "type": "text", 1013 + "primaryKey": false, 1014 + "notNull": false, 1015 + "autoincrement": false 1016 + }, 1017 + "disc_number": { 1018 + "name": "disc_number", 1019 + "type": "integer", 1020 + "primaryKey": false, 1021 + "notNull": false, 1022 + "autoincrement": false 1023 + }, 1024 + "lyrics": { 1025 + "name": "lyrics", 1026 + "type": "text", 1027 + "primaryKey": false, 1028 + "notNull": false, 1029 + "autoincrement": false 1030 + }, 1031 + "composer": { 1032 + "name": "composer", 1033 + "type": "text", 1034 + "primaryKey": false, 1035 + "notNull": false, 1036 + "autoincrement": false 1037 + }, 1038 + "genre": { 1039 + "name": "genre", 1040 + "type": "text", 1041 + "primaryKey": false, 1042 + "notNull": false, 1043 + "autoincrement": false 1044 + }, 1045 + "label": { 1046 + "name": "label", 1047 + "type": "text", 1048 + "primaryKey": false, 1049 + "notNull": false, 1050 + "autoincrement": false 1051 + }, 1052 + "copyright_message": { 1053 + "name": "copyright_message", 1054 + "type": "text", 1055 + "primaryKey": false, 1056 + "notNull": false, 1057 + "autoincrement": false 1058 + }, 1059 + "uri": { 1060 + "name": "uri", 1061 + "type": "text", 1062 + "primaryKey": false, 1063 + "notNull": false, 1064 + "autoincrement": false 1065 + }, 1066 + "cid": { 1067 + "name": "cid", 1068 + "type": "text", 1069 + "primaryKey": false, 1070 + "notNull": true, 1071 + "autoincrement": false 1072 + }, 1073 + "album_uri": { 1074 + "name": "album_uri", 1075 + "type": "text", 1076 + "primaryKey": false, 1077 + "notNull": false, 1078 + "autoincrement": false 1079 + }, 1080 + "artist_uri": { 1081 + "name": "artist_uri", 1082 + "type": "text", 1083 + "primaryKey": false, 1084 + "notNull": false, 1085 + "autoincrement": false 1086 + }, 1087 + "created_at": { 1088 + "name": "created_at", 1089 + "type": "integer", 1090 + "primaryKey": false, 1091 + "notNull": true, 1092 + "autoincrement": false, 1093 + "default": "(unixepoch())" 1094 + }, 1095 + "updated_at": { 1096 + "name": "updated_at", 1097 + "type": "integer", 1098 + "primaryKey": false, 1099 + "notNull": true, 1100 + "autoincrement": false, 1101 + "default": "(unixepoch())" 1102 + } 1103 + }, 1104 + "indexes": { 1105 + "tracks_mb_id_unique": { 1106 + "name": "tracks_mb_id_unique", 1107 + "columns": [ 1108 + "mb_id" 1109 + ], 1110 + "isUnique": true 1111 + }, 1112 + "tracks_youtube_link_unique": { 1113 + "name": "tracks_youtube_link_unique", 1114 + "columns": [ 1115 + "youtube_link" 1116 + ], 1117 + "isUnique": true 1118 + }, 1119 + "tracks_spotify_link_unique": { 1120 + "name": "tracks_spotify_link_unique", 1121 + "columns": [ 1122 + "spotify_link" 1123 + ], 1124 + "isUnique": true 1125 + }, 1126 + "tracks_apple_music_link_unique": { 1127 + "name": "tracks_apple_music_link_unique", 1128 + "columns": [ 1129 + "apple_music_link" 1130 + ], 1131 + "isUnique": true 1132 + }, 1133 + "tracks_tidal_link_unique": { 1134 + "name": "tracks_tidal_link_unique", 1135 + "columns": [ 1136 + "tidal_link" 1137 + ], 1138 + "isUnique": true 1139 + }, 1140 + "tracks_uri_unique": { 1141 + "name": "tracks_uri_unique", 1142 + "columns": [ 1143 + "uri" 1144 + ], 1145 + "isUnique": true 1146 + }, 1147 + "tracks_cid_unique": { 1148 + "name": "tracks_cid_unique", 1149 + "columns": [ 1150 + "cid" 1151 + ], 1152 + "isUnique": true 1153 + }, 1154 + "idx_title_artist_album_albumartist": { 1155 + "name": "idx_title_artist_album_albumartist", 1156 + "columns": [ 1157 + "title", 1158 + "artist", 1159 + "album", 1160 + "album_artist" 1161 + ], 1162 + "isUnique": false 1163 + } 1164 + }, 1165 + "foreignKeys": {}, 1166 + "compositePrimaryKeys": {}, 1167 + "uniqueConstraints": {}, 1168 + "checkConstraints": {} 1169 + }, 1170 + "user_albums": { 1171 + "name": "user_albums", 1172 + "columns": { 1173 + "id": { 1174 + "name": "id", 1175 + "type": "text", 1176 + "primaryKey": true, 1177 + "notNull": true, 1178 + "autoincrement": false 1179 + }, 1180 + "user_id": { 1181 + "name": "user_id", 1182 + "type": "text", 1183 + "primaryKey": false, 1184 + "notNull": true, 1185 + "autoincrement": false 1186 + }, 1187 + "album_id": { 1188 + "name": "album_id", 1189 + "type": "text", 1190 + "primaryKey": false, 1191 + "notNull": true, 1192 + "autoincrement": false 1193 + }, 1194 + "created_at": { 1195 + "name": "created_at", 1196 + "type": "integer", 1197 + "primaryKey": false, 1198 + "notNull": true, 1199 + "autoincrement": false, 1200 + "default": "(unixepoch())" 1201 + }, 1202 + "updated_at": { 1203 + "name": "updated_at", 1204 + "type": "integer", 1205 + "primaryKey": false, 1206 + "notNull": true, 1207 + "autoincrement": false, 1208 + "default": "(unixepoch())" 1209 + }, 1210 + "scrobbles": { 1211 + "name": "scrobbles", 1212 + "type": "integer", 1213 + "primaryKey": false, 1214 + "notNull": false, 1215 + "autoincrement": false 1216 + }, 1217 + "uri": { 1218 + "name": "uri", 1219 + "type": "text", 1220 + "primaryKey": false, 1221 + "notNull": true, 1222 + "autoincrement": false 1223 + } 1224 + }, 1225 + "indexes": { 1226 + "user_albums_uri_unique": { 1227 + "name": "user_albums_uri_unique", 1228 + "columns": [ 1229 + "uri" 1230 + ], 1231 + "isUnique": true 1232 + }, 1233 + "user_albums_unique_index": { 1234 + "name": "user_albums_unique_index", 1235 + "columns": [ 1236 + "user_id", 1237 + "album_id" 1238 + ], 1239 + "isUnique": true 1240 + } 1241 + }, 1242 + "foreignKeys": { 1243 + "user_albums_user_id_users_id_fk": { 1244 + "name": "user_albums_user_id_users_id_fk", 1245 + "tableFrom": "user_albums", 1246 + "tableTo": "users", 1247 + "columnsFrom": [ 1248 + "user_id" 1249 + ], 1250 + "columnsTo": [ 1251 + "id" 1252 + ], 1253 + "onDelete": "no action", 1254 + "onUpdate": "no action" 1255 + }, 1256 + "user_albums_album_id_albums_id_fk": { 1257 + "name": "user_albums_album_id_albums_id_fk", 1258 + "tableFrom": "user_albums", 1259 + "tableTo": "albums", 1260 + "columnsFrom": [ 1261 + "album_id" 1262 + ], 1263 + "columnsTo": [ 1264 + "id" 1265 + ], 1266 + "onDelete": "no action", 1267 + "onUpdate": "no action" 1268 + } 1269 + }, 1270 + "compositePrimaryKeys": {}, 1271 + "uniqueConstraints": {}, 1272 + "checkConstraints": {} 1273 + }, 1274 + "user_artists": { 1275 + "name": "user_artists", 1276 + "columns": { 1277 + "id": { 1278 + "name": "id", 1279 + "type": "text", 1280 + "primaryKey": true, 1281 + "notNull": true, 1282 + "autoincrement": false 1283 + }, 1284 + "user_id": { 1285 + "name": "user_id", 1286 + "type": "text", 1287 + "primaryKey": false, 1288 + "notNull": true, 1289 + "autoincrement": false 1290 + }, 1291 + "artist_id": { 1292 + "name": "artist_id", 1293 + "type": "text", 1294 + "primaryKey": false, 1295 + "notNull": true, 1296 + "autoincrement": false 1297 + }, 1298 + "created_at": { 1299 + "name": "created_at", 1300 + "type": "integer", 1301 + "primaryKey": false, 1302 + "notNull": true, 1303 + "autoincrement": false, 1304 + "default": "(unixepoch())" 1305 + }, 1306 + "updated_at": { 1307 + "name": "updated_at", 1308 + "type": "integer", 1309 + "primaryKey": false, 1310 + "notNull": true, 1311 + "autoincrement": false, 1312 + "default": "(unixepoch())" 1313 + }, 1314 + "scrobbles": { 1315 + "name": "scrobbles", 1316 + "type": "integer", 1317 + "primaryKey": false, 1318 + "notNull": false, 1319 + "autoincrement": false 1320 + }, 1321 + "uri": { 1322 + "name": "uri", 1323 + "type": "text", 1324 + "primaryKey": false, 1325 + "notNull": true, 1326 + "autoincrement": false 1327 + } 1328 + }, 1329 + "indexes": { 1330 + "user_artists_uri_unique": { 1331 + "name": "user_artists_uri_unique", 1332 + "columns": [ 1333 + "uri" 1334 + ], 1335 + "isUnique": true 1336 + }, 1337 + "user_artists_unique_index": { 1338 + "name": "user_artists_unique_index", 1339 + "columns": [ 1340 + "user_id", 1341 + "artist_id" 1342 + ], 1343 + "isUnique": true 1344 + } 1345 + }, 1346 + "foreignKeys": { 1347 + "user_artists_user_id_users_id_fk": { 1348 + "name": "user_artists_user_id_users_id_fk", 1349 + "tableFrom": "user_artists", 1350 + "tableTo": "users", 1351 + "columnsFrom": [ 1352 + "user_id" 1353 + ], 1354 + "columnsTo": [ 1355 + "id" 1356 + ], 1357 + "onDelete": "no action", 1358 + "onUpdate": "no action" 1359 + }, 1360 + "user_artists_artist_id_artists_id_fk": { 1361 + "name": "user_artists_artist_id_artists_id_fk", 1362 + "tableFrom": "user_artists", 1363 + "tableTo": "artists", 1364 + "columnsFrom": [ 1365 + "artist_id" 1366 + ], 1367 + "columnsTo": [ 1368 + "id" 1369 + ], 1370 + "onDelete": "no action", 1371 + "onUpdate": "no action" 1372 + } 1373 + }, 1374 + "compositePrimaryKeys": {}, 1375 + "uniqueConstraints": {}, 1376 + "checkConstraints": {} 1377 + }, 1378 + "user_tracks": { 1379 + "name": "user_tracks", 1380 + "columns": { 1381 + "id": { 1382 + "name": "id", 1383 + "type": "text", 1384 + "primaryKey": true, 1385 + "notNull": true, 1386 + "autoincrement": false 1387 + }, 1388 + "user_id": { 1389 + "name": "user_id", 1390 + "type": "text", 1391 + "primaryKey": false, 1392 + "notNull": true, 1393 + "autoincrement": false 1394 + }, 1395 + "track_id": { 1396 + "name": "track_id", 1397 + "type": "text", 1398 + "primaryKey": false, 1399 + "notNull": true, 1400 + "autoincrement": false 1401 + }, 1402 + "created_at": { 1403 + "name": "created_at", 1404 + "type": "integer", 1405 + "primaryKey": false, 1406 + "notNull": true, 1407 + "autoincrement": false, 1408 + "default": "(unixepoch())" 1409 + }, 1410 + "updated_at": { 1411 + "name": "updated_at", 1412 + "type": "integer", 1413 + "primaryKey": false, 1414 + "notNull": true, 1415 + "autoincrement": false, 1416 + "default": "(unixepoch())" 1417 + }, 1418 + "scrobbles": { 1419 + "name": "scrobbles", 1420 + "type": "integer", 1421 + "primaryKey": false, 1422 + "notNull": false, 1423 + "autoincrement": false 1424 + }, 1425 + "uri": { 1426 + "name": "uri", 1427 + "type": "text", 1428 + "primaryKey": false, 1429 + "notNull": true, 1430 + "autoincrement": false 1431 + } 1432 + }, 1433 + "indexes": { 1434 + "user_tracks_uri_unique": { 1435 + "name": "user_tracks_uri_unique", 1436 + "columns": [ 1437 + "uri" 1438 + ], 1439 + "isUnique": true 1440 + }, 1441 + "user_tracks_unique_index": { 1442 + "name": "user_tracks_unique_index", 1443 + "columns": [ 1444 + "user_id", 1445 + "track_id" 1446 + ], 1447 + "isUnique": true 1448 + } 1449 + }, 1450 + "foreignKeys": { 1451 + "user_tracks_user_id_users_id_fk": { 1452 + "name": "user_tracks_user_id_users_id_fk", 1453 + "tableFrom": "user_tracks", 1454 + "tableTo": "users", 1455 + "columnsFrom": [ 1456 + "user_id" 1457 + ], 1458 + "columnsTo": [ 1459 + "id" 1460 + ], 1461 + "onDelete": "no action", 1462 + "onUpdate": "no action" 1463 + }, 1464 + "user_tracks_track_id_tracks_id_fk": { 1465 + "name": "user_tracks_track_id_tracks_id_fk", 1466 + "tableFrom": "user_tracks", 1467 + "tableTo": "tracks", 1468 + "columnsFrom": [ 1469 + "track_id" 1470 + ], 1471 + "columnsTo": [ 1472 + "id" 1473 + ], 1474 + "onDelete": "no action", 1475 + "onUpdate": "no action" 1476 + } 1477 + }, 1478 + "compositePrimaryKeys": {}, 1479 + "uniqueConstraints": {}, 1480 + "checkConstraints": {} 1481 + }, 1482 + "users": { 1483 + "name": "users", 1484 + "columns": { 1485 + "id": { 1486 + "name": "id", 1487 + "type": "text", 1488 + "primaryKey": true, 1489 + "notNull": true, 1490 + "autoincrement": false 1491 + }, 1492 + "did": { 1493 + "name": "did", 1494 + "type": "text", 1495 + "primaryKey": false, 1496 + "notNull": true, 1497 + "autoincrement": false 1498 + }, 1499 + "display_name": { 1500 + "name": "display_name", 1501 + "type": "text", 1502 + "primaryKey": false, 1503 + "notNull": false, 1504 + "autoincrement": false 1505 + }, 1506 + "handle": { 1507 + "name": "handle", 1508 + "type": "text", 1509 + "primaryKey": false, 1510 + "notNull": true, 1511 + "autoincrement": false 1512 + }, 1513 + "avatar": { 1514 + "name": "avatar", 1515 + "type": "text", 1516 + "primaryKey": false, 1517 + "notNull": true, 1518 + "autoincrement": false 1519 + }, 1520 + "created_at": { 1521 + "name": "created_at", 1522 + "type": "integer", 1523 + "primaryKey": false, 1524 + "notNull": true, 1525 + "autoincrement": false, 1526 + "default": "(unixepoch())" 1527 + }, 1528 + "updated_at": { 1529 + "name": "updated_at", 1530 + "type": "integer", 1531 + "primaryKey": false, 1532 + "notNull": true, 1533 + "autoincrement": false, 1534 + "default": "(unixepoch())" 1535 + } 1536 + }, 1537 + "indexes": { 1538 + "users_did_unique": { 1539 + "name": "users_did_unique", 1540 + "columns": [ 1541 + "did" 1542 + ], 1543 + "isUnique": true 1544 + }, 1545 + "users_handle_unique": { 1546 + "name": "users_handle_unique", 1547 + "columns": [ 1548 + "handle" 1549 + ], 1550 + "isUnique": true 1551 + } 1552 + }, 1553 + "foreignKeys": {}, 1554 + "compositePrimaryKeys": {}, 1555 + "uniqueConstraints": {}, 1556 + "checkConstraints": {} 1557 + } 1558 + }, 1559 + "views": {}, 1560 + "enums": {}, 1561 + "_meta": { 1562 + "schemas": {}, 1563 + "tables": {}, 1564 + "columns": {} 1565 + }, 1566 + "internal": { 1567 + "indexes": {} 1568 + } 1569 + }
+7
apps/cli/drizzle/meta/_journal.json
··· 8 8 "when": 1768065262210, 9 9 "tag": "0000_parallel_paper_doll", 10 10 "breakpoints": true 11 + }, 12 + { 13 + "idx": 1, 14 + "version": "6", 15 + "when": 1768571013590, 16 + "tag": "0001_awesome_gabe_jones", 17 + "breakpoints": true 11 18 } 12 19 ] 13 20 }
+40 -32
apps/cli/src/schema/tracks.ts
··· 1 1 import { type InferInsertModel, type InferSelectModel, sql } from "drizzle-orm"; 2 - import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core"; 2 + import { integer, sqliteTable, text, index } from "drizzle-orm/sqlite-core"; 3 3 4 - const tracks = sqliteTable("tracks", { 5 - id: text("id").primaryKey().notNull(), 6 - title: text("title").notNull(), 7 - artist: text("artist").notNull(), 8 - albumArtist: text("album_artist").notNull(), 9 - albumArt: text("album_art"), 10 - album: text("album").notNull(), 11 - trackNumber: integer("track_number"), 12 - duration: integer("duration").notNull(), 13 - mbId: text("mb_id").unique(), 14 - youtubeLink: text("youtube_link").unique(), 15 - spotifyLink: text("spotify_link").unique(), 16 - appleMusicLink: text("apple_music_link").unique(), 17 - tidalLink: text("tidal_link").unique(), 18 - discNumber: integer("disc_number"), 19 - lyrics: text("lyrics"), 20 - composer: text("composer"), 21 - genre: text("genre"), 22 - label: text("label"), 23 - copyrightMessage: text("copyright_message"), 24 - uri: text("uri").unique(), 25 - cid: text("cid").unique().notNull(), 26 - albumUri: text("album_uri"), 27 - artistUri: text("artist_uri"), 28 - createdAt: integer("created_at", { mode: "timestamp" }) 29 - .notNull() 30 - .default(sql`(unixepoch())`), 31 - updatedAt: integer("updated_at", { mode: "timestamp" }) 32 - .notNull() 33 - .default(sql`(unixepoch())`), 34 - }); 4 + const tracks = sqliteTable( 5 + "tracks", 6 + { 7 + id: text("id").primaryKey().notNull(), 8 + title: text("title").notNull(), 9 + artist: text("artist").notNull(), 10 + albumArtist: text("album_artist").notNull(), 11 + albumArt: text("album_art"), 12 + album: text("album").notNull(), 13 + trackNumber: integer("track_number"), 14 + duration: integer("duration").notNull(), 15 + mbId: text("mb_id").unique(), 16 + youtubeLink: text("youtube_link").unique(), 17 + spotifyLink: text("spotify_link").unique(), 18 + appleMusicLink: text("apple_music_link").unique(), 19 + tidalLink: text("tidal_link").unique(), 20 + discNumber: integer("disc_number"), 21 + lyrics: text("lyrics"), 22 + composer: text("composer"), 23 + genre: text("genre"), 24 + label: text("label"), 25 + copyrightMessage: text("copyright_message"), 26 + uri: text("uri").unique(), 27 + cid: text("cid").unique().notNull(), 28 + albumUri: text("album_uri"), 29 + artistUri: text("artist_uri"), 30 + createdAt: integer("created_at", { mode: "timestamp" }) 31 + .notNull() 32 + .default(sql`(unixepoch())`), 33 + updatedAt: integer("updated_at", { mode: "timestamp" }) 34 + .notNull() 35 + .default(sql`(unixepoch())`), 36 + }, 37 + (t) => ({ 38 + idx_title_artist_album_albumartist: index( 39 + "idx_title_artist_album_albumartist", 40 + ).on(t.title, t.artist, t.album, t.albumArtist), 41 + }), 42 + ); 35 43 36 44 export type SelectTrack = InferSelectModel<typeof tracks>; 37 45 export type InsertTrack = InferInsertModel<typeof tracks>;