feat: migrate to PostgreSQL and enhance playlist curation

- Migrate database from SQLite to PostgreSQL (100.91.248.114:5433)
- Fix playlist curation to use actual top tracks instead of AI name matching
- Add /playlists/history endpoint for historical playlist viewing
- Add Playlist Archives section to frontend with expandable history
- Add playlist-modify-* scopes to Spotify OAuth for playlist creation
- Rewrite Genius client to use official API (fixes 403 scraping blocks)
- Ensure playlists are created on Spotify before curation attempts
- Add DATABASE.md documentation for PostgreSQL schema
- Add migrations for PlaylistConfig and composition storage
This commit is contained in:
bnair123
2025-12-30 22:24:56 +04:00
parent 26b4895695
commit 272148c5bf
19 changed files with 1130 additions and 145 deletions

View File

@@ -0,0 +1,32 @@
"""add_composition_to_snapshot
Revision ID: 24fafb6f6e98
Revises: 86ea83950f3d
Create Date: 2025-12-30 10:43:05.933962
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '24fafb6f6e98'
down_revision: Union[str, Sequence[str], None] = '86ea83950f3d'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('analysis_snapshots', sa.Column('playlist_composition', sa.JSON(), nullable=True))
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('analysis_snapshots', 'playlist_composition')
# ### end Alembic commands ###

View File

@@ -0,0 +1,41 @@
"""add_playlist_config_table
Revision ID: 7e28cc511ef8
Revises: 5ed73db9bab9
Create Date: 2025-12-30 10:30:36.775553
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '7e28cc511ef8'
down_revision: Union[str, Sequence[str], None] = '5ed73db9bab9'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('playlist_config',
sa.Column('key', sa.String(), nullable=False),
sa.Column('spotify_id', sa.String(), nullable=False),
sa.Column('last_updated', sa.DateTime(), nullable=True),
sa.Column('current_theme', sa.String(), nullable=True),
sa.Column('description', sa.String(), nullable=True),
sa.PrimaryKeyConstraint('key')
)
op.create_index(op.f('ix_playlist_config_key'), 'playlist_config', ['key'], unique=False)
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_playlist_config_key'), table_name='playlist_config')
op.drop_table('playlist_config')
# ### end Alembic commands ###

View File

@@ -0,0 +1,32 @@
"""add_composition_to_playlist_config
Revision ID: 86ea83950f3d
Revises: 7e28cc511ef8
Create Date: 2025-12-30 10:39:27.121477
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '86ea83950f3d'
down_revision: Union[str, Sequence[str], None] = '7e28cc511ef8'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('playlist_config', sa.Column('composition', sa.JSON(), nullable=True))
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('playlist_config', 'composition')
# ### end Alembic commands ###