{"id":15104813,"url":"https://github.com/travisvn/supabase-inactive-fix","last_synced_at":"2025-10-23T00:30:41.346Z","repository":{"id":257319421,"uuid":"857901289","full_name":"travisvn/supabase-inactive-fix","owner":"travisvn","description":"Stop Supabase projects from being paused due to inactivity","archived":false,"fork":false,"pushed_at":"2024-10-28T00:45:49.000Z","size":18,"stargazers_count":11,"open_issues_count":0,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-30T16:40:57.446Z","etag":null,"topics":["automation","cronjobs","database","postgres","python","sql","supabase"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/travisvn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-15T22:30:30.000Z","updated_at":"2025-01-30T10:41:11.000Z","dependencies_parsed_at":"2024-09-16T00:44:17.287Z","dependency_job_id":"b09a40ec-edac-4a78-a5e4-bba836565fd2","html_url":"https://github.com/travisvn/supabase-inactive-fix","commit_stats":{"total_commits":5,"total_committers":2,"mean_commits":2.5,"dds":"0.19999999999999996","last_synced_commit":"1d69537df6c5d876c51a5da43e6eb7bd4e085f6d"},"previous_names":["travisvn/supabase-inactive-fix"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/travisvn%2Fsupabase-inactive-fix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/travisvn%2Fsupabase-inactive-fix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/travisvn%2Fsupabase-inactive-fix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/travisvn%2Fsupabase-inactive-fix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/travisvn","download_url":"https://codeload.github.com/travisvn/supabase-inactive-fix/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237754152,"owners_count":19360654,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","cronjobs","database","postgres","python","sql","supabase"],"created_at":"2024-09-25T20:02:36.190Z","updated_at":"2025-10-23T00:30:41.335Z","avatar_url":"https://github.com/travisvn.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Supabase Inactive Fix\n\n![GitHub stars](https://img.shields.io/github/stars/travisvn/supabase-inactive-fix?style=social)\n![GitHub forks](https://img.shields.io/github/forks/travisvn/supabase-inactive-fix?style=social)\n![GitHub repo size](https://img.shields.io/github/repo-size/travisvn/supabase-inactive-fix)\n![GitHub top language](https://img.shields.io/github/languages/top/travisvn/supabase-inactive-fix)\n![GitHub last commit](https://img.shields.io/github/last-commit/travisvn/supabase-inactive-fix?color=red)\n\nThis project helps prevent Supabase projects from pausing due to inactivity by periodically inserting, monitoring, and deleting entries in the specified tables of multiple Supabase databases. The project uses a configuration file (`config.json`) to define multiple databases and automate the keep-alive actions.\n\n## Features ⭐️\n\n- Insert a random string into a specified table for each Supabase database.\n- Monitor the number of entries in the table.\n- Automatically delete entries if the table contains more than a specified number of records.\n- Log successes and failures, and generate a detailed status report.\n\n## Setup 🚀\n\n\u003e **💡 Quick Start:** For the easiest setup, skip to [Deployment Options](#deployment-options-) and use **GitHub Actions** (serverless, no installation required).\n\n### Local Development Setup\n\n1. Clone the repository:\n\n    ```bash\n    git clone https://github.com/travisvn/supabase-inactive-fix.git\n    cd supabase-inactive-fix\n    ```\n    \n2. Install the required dependencies:\n    \n    ```bash\n    python -m venv venv\n    source venv/bin/activate  # On Windows use `venv\\Scripts\\activate`\n    pip install -r requirements.txt\n    ```\n    \n3. Create a `config.json` file in the project root. This file defines your Supabase databases. \n\n   \n    Example configuration:\n    \n    ```json\n    [\n      {\n        \"name\": \"Database1\",\n        \"supabase_url\": \"https://your-supabase-url-1.supabase.co\",\n        \"supabase_key_env\": \"SUPABASE_KEY_1\",  // Use environment variable for the key\n        \"table_name\": \"KeepAlive\"\n      },\n      {\n        \"name\": \"Database2\",\n        \"supabase_url\": \"https://your-supabase-url-2.supabase.co\",\n        \"supabase_key\": \"your-direct-supabase-key\",  // Directly define the key\n        \"table_name\": \"keep-alive\"\n      }\n    ]\n    ```\n\n    [See the section below for how to easily configure your database](#supabase-database-setup-)\n    \n    ### Environment Variables Explained\n    \n    In the `config.json` file, you can define either:\n    \n    - **Direct API Key**: Use the `\"supabase_key\"` field to directly specify your Supabase API key.\n    - **Environment Variable**: Use the `\"supabase_key_env\"` field to reference an environment variable where the key is stored. This is more secure, especially when running the script in different environments.\n    \n    #### Example:\n    \n    - `\"supabase_key_env\": \"SUPABASE_KEY_1\"`: This tells the script to look for an environment variable called `SUPABASE_KEY_1` that contains the actual API key.\n    - `\"supabase_key\": \"your-direct-supabase-key\"`: This directly provides the API key within the `config.json` file, which is less secure but simpler for local setups.\n\n4. Set up your environment variables _if you're using them_:\n    \n    Create a `.env` file and store variables there\n    \n    ```\n    SUPABASE_KEY_1=\"your-supabase-key-1\"\n    SUPABASE_KEY_2=\"your-supabase-key-2\"\n    ```\n    \n5. Run the script:\n    \n    ```bash\n    python main.py\n    ```\n\n## Deployment Options 🚀\n\n### Option 1: GitHub Actions (Recommended - Serverless)\n\nThe easiest way to deploy this project is using GitHub Actions, which runs completely serverless and free on GitHub's infrastructure.\n\n#### Steps:\n\n1. **Fork this repository** to your GitHub account.\n\n2. **Create your `config.json`** file:\n   - Copy `config.example.json` to `config.json`\n   - Update with your Supabase project URLs and table names\n   - Use `supabase_key_env` (not `supabase_key`) to reference environment variables\n\n   ```json\n   [\n     {\n       \"name\": \"MyProject\",\n       \"supabase_url\": \"https://your-project-id.supabase.co\",\n       \"supabase_key_env\": \"SUPABASE_KEY_1\",\n       \"table_name\": \"keep-alive\"\n     }\n   ]\n   ```\n\n3. **Commit and push your `config.json`** to your forked repository.\n\n4. **Set up GitHub Secrets and Variables**:\n   - Go to your forked repository on GitHub\n   - Navigate to **Settings** \u003e **Secrets and variables** \u003e **Actions**\n\n   **First, enable the workflow (Variables tab):**\n   - Click the **Variables** tab\n   - Click **New repository variable**\n   - Name: `ENABLE_GITHUB_ACTIONS`\n   - Value: `true`\n\n   **Then, add your API keys (Secrets tab):**\n   - Click the **Secrets** tab\n   - Click **New repository secret**\n   - Add secrets for each database (matching the env var names in your `config.json`):\n     - Name: `SUPABASE_KEY_1`\n     - Value: Your Supabase API key\n   - Repeat for all your databases (`SUPABASE_KEY_2`, `SUPABASE_KEY_3`, etc.)\n\n5. **Enable GitHub Actions**:\n   - Go to the **Actions** tab in your forked repository\n   - Click \"I understand my workflows, go ahead and enable them\"\n\n6. **Test the workflow**:\n   - In the Actions tab, select \"Supabase Keep-Alive\"\n   - Click \"Run workflow\" to test it manually\n   - Check the logs to ensure everything works\n\n**That's it!** The workflow will automatically run every Monday and Thursday at midnight UTC, keeping your Supabase databases active.\n\n\u003e **📝 Note for Existing Users:** If you're currently using a local cron job and pull this update, the GitHub Actions workflow will NOT run automatically. It only activates when you explicitly set the `ENABLE_GITHUB_ACTIONS` variable to `true`. You can:\n\u003e - **Keep using your cron job**: Do nothing, the workflow stays disabled\n\u003e - **Switch to GitHub Actions**: Follow the setup steps above and disable your cron job\n\u003e - **Use both** (not recommended): Enable both, but adjust schedules to avoid conflicts\n\n#### Customizing the Schedule\n\nEdit `.github/workflows/keep-alive.yml` and modify the cron expression:\n\n```yaml\nschedule:\n  - cron: '0 0 * * 1,4'  # Currently: Monday and Thursday at midnight UTC\n```\n\n### Option 2: Local Cron Job\n\nIf you prefer to run the script on your own machine or server, you can set up a cron job.\n\n1. Follow the initial setup steps 1-4 from the main [Setup](#setup-) section above.\n\n2. Set up a cron job (see [Cron Job Setup](#cron-job-setup-%EF%B8%8F) below for details).\n\n## Supabase Database Setup 🔧\n\nThis project is predicated on accessing a `keep-alive` table in your Postgres database on Supabase. \n\n### Sample SQL \n\nHere's a SQL query for a `keep-alive` table \n\n```sql\nCREATE TABLE \"keep-alive\" (\n  id BIGINT generated BY DEFAULT AS IDENTITY,\n  name text NULL DEFAULT '':: text,\n  random uuid NULL DEFAULT gen_random_uuid (),\n  CONSTRAINT \"keep-alive_pkey\" PRIMARY key (id)\n);\n\nINSERT INTO\n  \"keep-alive\"(name)\nVALUES\n  ('placeholder'),\n  ('example');\n```\n    \n\n## Cron Job Setup ⏱️\n\nTo automate this script, you can create a cron job that runs the script periodically. Below are instructions for setting this up on macOS, Linux, and Windows.\n\n### macOS/Linux\n\n1. Open your crontab file for editing:\n    \n    ```bash\n    crontab -e\n    ```\n    \n2. Add a new cron job to run the script every Monday and Thursday at midnight:\n    \n    ```bash\n    0 0 * * 1,4 cd /path/to/your/project \u0026\u0026 /path/to/your/project/venv/bin/python main.py \u003e\u003e /path/to/your/project/logfile.log 2\u003e\u00261\n    ```\n    \n\nThis example cron job will:\n\n- Navigate to the project directory.\n- Run the Python script using the virtual environment.\n- Append the output to a logfile.\n\nFor reference, here’s an example used in development:\n\n```bash\n0 0 * * 1,4 cd /Users/travis/Workspace/supabase-inactive-fix \u0026\u0026 /Users/travis/Workspace/supabase-inactive-fix/venv/bin/python main.py \u003e\u003e /Users/travis/Workspace/supabase-inactive-fix/logfile.log 2\u003e\u00261\n```\n\n### Windows (Task Scheduler)\n\nWindows does not have cron jobs, but you can achieve similar functionality using Task Scheduler.\n\n1. Open **Task Scheduler** and select **Create Basic Task**.\n    \n2. Name the task and set the trigger to run weekly.\n    \n3. Set the days (e.g., Monday and Thursday) and time (e.g., midnight) when the script should run.\n    \n4. In the **Action** step, select **Start a Program**, and point it to your Python executable within your virtual environment. For example:\n    \n    ```vbnet\n    C:\\path\\to\\your\\project\\venv\\Scripts\\python.exe\n    ```\n    \n5. In the **Arguments** field, specify the path to the script:\n    \n    ```vbnet\n    C:\\path\\to\\your\\project\\main.py\n    ```\n    \n6. Save the task. The script will now run automatically according to the schedule you specified.\n    \n\n## Contribution\n\nFeel free to open an issue or submit a pull request if you'd like to contribute to this project.\n\n## License\n\nThis project is licensed under the MIT License. See the `LICENSE` file for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftravisvn%2Fsupabase-inactive-fix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftravisvn%2Fsupabase-inactive-fix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftravisvn%2Fsupabase-inactive-fix/lists"}