801e6a050b
- Documentation archivée et réorganisée - Backend: Ajout tests, migrations, library service, rate limiting - Frontend: Suppression Flutter, focus sur interface web HTML/JS - Tailwind CSS ajouté pour le style - Améliorations UX et corrections bugs Generated with [Claude Code](https://claude.com/claude-code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
73 lines
1.3 KiB
Markdown
73 lines
1.3 KiB
Markdown
# Quick Start - Database Migration
|
|
|
|
## Apply the Migration
|
|
|
|
```bash
|
|
cd /opt/audiOhm/backend
|
|
|
|
# Option 1: Using the helper script
|
|
./run_migration.sh upgrade
|
|
|
|
# Option 2: Using Alembic directly
|
|
alembic upgrade head
|
|
```
|
|
|
|
## Verify Migration Success
|
|
|
|
```bash
|
|
# Check current version
|
|
./run_migration.sh current
|
|
|
|
# Or using Alembic directly
|
|
alembic current
|
|
```
|
|
|
|
## What Gets Created
|
|
|
|
Two new tables will be created:
|
|
|
|
1. **listening_history** - Track listening records for users
|
|
2. **liked_tracks** - User's favorite/liked tracks
|
|
|
|
## Need Help?
|
|
|
|
```bash
|
|
# Show all available commands
|
|
./run_migration.sh help
|
|
|
|
# Or read the full guide
|
|
cat ALEMBIC_GUIDE.md
|
|
```
|
|
|
|
## Revert if Needed
|
|
|
|
```bash
|
|
# Revert the migration
|
|
./run_migration.sh downgrade-1
|
|
|
|
# Or using Alembic
|
|
alembic downgrade -1
|
|
```
|
|
|
|
## Check Tables in Database
|
|
|
|
```bash
|
|
sudo -u postgres psql spotify_le_2
|
|
\dt
|
|
\q
|
|
```
|
|
|
|
## Important Notes
|
|
|
|
- Make sure PostgreSQL is running before applying migration
|
|
- The migration uses CASCADE deletes - deleting a user or track will automatically remove related history/likes
|
|
- The `liked_tracks` table has a UNIQUE constraint to prevent duplicate likes
|
|
- Both tables have optimized indexes for common queries
|
|
|
|
## Status
|
|
|
|
✅ Migration file created and validated
|
|
✅ Ready to apply to database
|
|
✅ Full downgrade support included
|
|
✅ Documentation complete
|