|
| 1 | +# Supabase Setup Guide for Mirarr |
| 2 | + |
| 3 | +This guide will help you set up Supabase to sync your watch history across devices. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +1. A Supabase account (free tier is sufficient) |
| 8 | +2. A Supabase project |
| 9 | + |
| 10 | +## Step 1: Create a Supabase Project |
| 11 | + |
| 12 | +1. Go to [supabase.com](https://supabase.com) and sign up/sign in |
| 13 | +2. Click "New Project" |
| 14 | +3. Choose your organization and enter project details |
| 15 | +4. The name doesn't matter. Don't change other settings |
| 16 | +5. For region choose somewhere closest to you for better latency |
| 17 | +6. Wait for the project to be created |
| 18 | + |
| 19 | + |
| 20 | +## Step 2: Create the Watch History Table |
| 21 | + |
| 22 | +1. In your Supabase dashboard, go to the "SQL Editor" |
| 23 | +2. Copy and paste the following SQL command to create the watch history table. Click run: |
| 24 | + |
| 25 | +```sql |
| 26 | +CREATE TABLE IF NOT EXISTS watch_history ( |
| 27 | + id BIGSERIAL PRIMARY KEY, |
| 28 | + tmdb_id INTEGER NOT NULL, |
| 29 | + title TEXT NOT NULL, |
| 30 | + type TEXT NOT NULL CHECK (type IN ('movie', 'tv')), |
| 31 | + poster_path TEXT, |
| 32 | + watched_at TIMESTAMPTZ NOT NULL, |
| 33 | + season_number INTEGER, |
| 34 | + episode_number INTEGER, |
| 35 | + episode_title TEXT, |
| 36 | + user_rating REAL, |
| 37 | + notes TEXT, |
| 38 | + created_at TIMESTAMPTZ DEFAULT NOW(), |
| 39 | + updated_at TIMESTAMPTZ DEFAULT NOW(), |
| 40 | + UNIQUE(tmdb_id, type, season_number, episode_number) |
| 41 | +); |
| 42 | +ALTER TABLE watch_history ENABLE ROW LEVEL SECURITY; |
| 43 | +CREATE POLICY "Allow all operations on watch_history" ON watch_history |
| 44 | +FOR ALL USING (true); |
| 45 | +``` |
| 46 | + |
| 47 | +## Step 3: Get Your Project Credentials |
| 48 | + |
| 49 | +1. In your Supabase dashboard, go to "Settings" > "Data API" |
| 50 | +2. Copy the following values: |
| 51 | + - **Project URL** (looks like `https://your-project-id.supabase.co`) |
| 52 | + - **Anon/Public Key** (the `anon` key, not the `service_role` key) |
| 53 | + |
| 54 | +## Step 4: Configure Mirarr |
| 55 | + |
| 56 | +1. Open Mirarr and go to Settings |
| 57 | +2. In the "Supabase Configuration" section: |
| 58 | + - Enter your **Project URL** in the "Supabase URL" field |
| 59 | + - Enter your **Anon Key** in the "Supabase Anon Key" field |
| 60 | +3. Click "Save Configuration" |
| 61 | +4. You should see a green checkmark indicating successful configuration |
| 62 | + |
| 63 | +## Step 5: Sync Your Data |
| 64 | + |
| 65 | + |
| 66 | +### Sync Behavior Details |
| 67 | + |
| 68 | +- **Upload**: Compares your local database with Supabase and ensures they match exactly. Items deleted locally will be removed from Supabase, and new/updated items will be uploaded. |
| 69 | +- **Download**: Merges remote data with local data without removing anything locally. |
| 70 | +- **Sync All**: Combines both operations for complete synchronization. |
| 71 | + |
| 72 | +## Security Notes |
| 73 | + |
| 74 | +- Don't share your url and anon key. The current setup has no authentication implemented. |
| 75 | + |
| 76 | +## Troubleshooting |
| 77 | + |
| 78 | +### "Failed to sync" error |
| 79 | +- Check your internet connection |
| 80 | +- Verify your Supabase URL and anon key are correct |
| 81 | +- Make sure the watch_history table exists in your Supabase project |
| 82 | + |
| 83 | +### Table doesn't exist error |
| 84 | +- Make sure you ran the SQL commands from Step 2 |
| 85 | +- Check that the table name is exactly `watch_history` |
| 86 | + |
| 87 | +### Project Paused |
| 88 | +If you don't upload or download anything from your project for 7 days on free tier, the project gets paused (Supabase will email you about it.). Just open up your Supabase dashboard and click resume if this happens. |
| 89 | + |
| 90 | + |
| 91 | +## Support |
| 92 | + |
| 93 | +If you encounter issues, please check: |
| 94 | +1. Supabase project status |
| 95 | +2. Network connectivity. Try with a VPN. |
| 96 | +3. Correct credentials in Mirarr settings |
0 commit comments