Stop Supabase Projects From Being Paused

stop-supabase-projects-from-being-paused

Keep Your Supabase Projects Active with Supabase Inactive Fix and Supabase Pause Prevention

Supabase is a powerful backend-as-a-service platform built on top of Postgres, providing developers with database hosting, authentication, and other essential services. However, if you’re running multiple side projects on Supabase, you’ve probably encountered the dreaded inactivity pause: if 7 days pass without activity, your Supabase project is paused, and the database becomes inactive.

To help you avoid this, I’ve created two GitHub projects that automate database activity to prevent pauses: Supabase Inactive Fix, written in Python, and Supabase Pause Prevention, designed for Next.js projects. In this post, I’ll walk you through how to set up and use these tools to keep your side projects running smoothly without manual intervention.

Why Supabase Pauses Inactive Projects

Supabase pauses any project that doesn’t see activity for 7 consecutive days. While this is a great cost-saving measure, it can cause frustration for developers with side projects or apps that aren’t accessed frequently. When a project is paused, it takes some time for the database to come back online when you need it, slowing down development and user experience.

The good news is you can keep your databases active by making automated calls to your projects, ensuring that activity is logged before the 7-day window ends.

Supabase Inactive Fix is a Python script designed to prevent your Supabase databases from going inactive. It works by making unique calls to each Supabase Postgres database you configure it to watch, ensuring that the necessary activity is logged. You can easily set it up to run as a cron job on any server or computer.

Key Features:

  • Written in Python for flexibility and ease of use.
  • Can be configured to watch multiple databases.
  • Runs as a scheduled cron job to automate the process.

Note: Supabase Inactive Fix will keep any Supabase project active — it’s not limited to Python projects by any means

How to Set Up Supabase Inactive Fix:

1. Clone the repository:

Start by cloning the Supabase Inactive Fix GitHub repo.

git clone https://github.com/travisvn/supabase-inactive-fix

2. Install Dependencies:

Navigate to the project folder and install the required dependencies using pip.

cd supabase-inactive-fix
python -m venv venv
source venv/bin/activate  # On Windows use `venvScriptsactivate`
pip install -r requirements.txt

3. Configure Your Databases:

Inside the project, there’s a configuration file config.json where you can add the Supabase databases you want to keep active. You’ll need your Supabase project URL and API keys.

[
  {
    "name": "Database1",
    "supabase_url": "https://your-supabase-url-1.supabase.co",
    "supabase_key_env": "SUPABASE_KEY_1",  // Use environment variable for the key
    "table_name": "KeepAlive"
  },
  {
    "name": "Database2",
    "supabase_url": "https://your-supabase-url-2.supabase.co",
    "supabase_key": "your-direct-supabase-key",  // Directly define the key
    "table_name": "keep-alive"
  }
]

4. Set Up a Cron Job:

To ensure your databases stay active, schedule the script to run at least once a week. If you’re using a Linux or Mac system, you can set up a cron job like this:

crontab -e

Add the following line to run the script every day at midnight:

0 0 * * 1,4 cd /path/to/your/project && /path/to/your/project/venv/bin/python main.py >> /path/to/your/project/logfile.log 2>&1

This ensures that your Supabase databases will always have activity within the 7-day window, keeping them from being paused.

View the README for a detailed explanation and walkthrough

Supabase Pause Prevention: An Alternative Using Next.js

For those who prefer working with Next.js, Supabase Pause Prevention is another option. While not as streamlined as the Python solution, it serves the same purpose by making calls to the APIs of other projects in your Supabase setup, ensuring that each project records activity.

Key Features:

  • Designed specifically for Next.js projects using Supabase.
  • Prevents project pauses by making API calls to keep databases active.
  • Easy integration with your existing Next.js setup.

How to Set Up Supabase Pause Prevention:

Solution / How it works

  • Creating a cron job (scheduled task) that makes a simple database call
    • (This keeps your Supabase project active)
  • Fetching keep-alive.ts API endpoints for the other projects, as Vercel limits free-tier users to one cron job.

Getting Started

Super simple to add to your existing Supabase project!

Configure your main project

Only 3 files matter

utils/supabase folder contains files provided in the Supabase docs for the Next.js Web App demo — Supabase

Everything else is boilerplate from Next.js create-next-app

Configuring your other Supabase projects

After selecting your primary project (the one that implements the code provided in this repository), you’ll want to add an API endpoint to your other Supabase projects

The only requirement is that this endpoint is reachable and makes a call to your Supabase database

API endpoint must make database call

Ensure the server doesn’t cache this

Refer to the README for more details here

Sample SQL

Any table and column can be called, but if you’d rather go with a generic, here’s a SQL query for a keep-alive table

CREATE TABLE "keep-alive" (
  id BIGINT generated BY DEFAULT AS IDENTITY,
  name text NULL DEFAULT '':: text,
  random uuid NULL DEFAULT gen_random_uuid (),
  CONSTRAINT "keep-alive_pkey" PRIMARY key (id)
);

INSERT INTO
  "keep-alive"(name)
VALUES
  ('placeholder'),
  ('example');

It is now strongly recommended to use a keep-alive table like the one above.

This is in light of the added features for optional database insertion & deletion actions

View the README for a detailed explanation and walkthrough

Wrapping it up

Whether you choose to use Python or integrate into your existing Next.js project, Supabase Inactive Fix and Supabase Pause Prevention are both excellent ways to keep your Supabase databases from being paused due to inactivity. With just a few steps, you can set up automated scripts to ensure your projects are always online and ready for use.

Check out the repositories on GitHub:

Both of these tools are easy to set up and will save you the hassle of manually unpausing your databases every week.

If you have any questions, feel free to leave a comment!

Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post
how-ct-quality-analysis-of-ev-batteries-can-help-address-demand-and-performance

How CT Quality Analysis of EV Batteries Can Help Address Demand and Performance

Next Post
week-4:-lab-4-merge-branches

Week 4: Lab 4 merge branches

Related Posts

「設計ミス」の社会を再編する:AIと共創する未来の働き方とシステム思考

こんにちは、Soraです。この記事をお読みいただき、ありがとうございます。突然ですが、少しだけ想像してみてください。朝、もう少しだけ布団の温もりを感じていたいのに、「仕事だから」と自分にムチを打って起き上がる。満員電車に身体を押し込まれ、会社に着けば成果を求められ、同僚のフォローに追われる。気づけば形式だけの会議が続き、帰宅する頃には自分のための時間はほとんど残っていない…。もし、こうした日々に少しでも心当たりがあるなら、ふと胸の奥で「このままで、本当にいいのだろうか?」という静かな声が聞こえることがあるのではないでしょうか。本稿では、その胸のざわめきを「個人の怠け」や「甘え」として片付けるのではなく、私たちを取り巻く社会そのものの「設計ミス」のシグナルとして捉え直すことを提案します。そして、その設計をどうすれば再編できるのか、具体的なデータも交えながら、皆さんと一緒に考えていきたいと思います。### 第一章|「労働=価値」という虚構の検証私たちはいつの間にか、「働くことが人間の価値を決める」という前提を内面化しています。しかし、この考え方は本当に自明なのでしょうか。いくつかのデータは、この前提が現代において大きな歪みを生んでいる可能性を示唆しています。 **異常に低い仕事への熱意:米ギャラップ社の調査によると、日本の「熱意あふれる社員」の割合はわずか5%。これは調査した139カ国中、最下位レベルです。多くの人が、仕事に対してポジティブな感情を持てずにいる現状が伺えます。* 構造的な高ストレス状態:厚生労働省の調査では、仕事で強いストレスを感じている労働者の割合は、常に半数を超えています。これは個人の精神的な強さの問題ではなく、労働環境そのものに構造的な問題が潜んでいることの現れです。* 先進国で低位の労働生産性:日本の時間当たり労働生産性は、OECD加盟38カ国中30位(2022年)と、長年低い水準にあります。長時間働き、高いストレスを感じているにもかかわらず、それが必ずしも高い成果に結びついていないのです。これらの事実は、「個人の努力が足りない」からではなく、「努力の方向性を規定する社会の設計そのもの」に無理が生じていることを示しているのではないでしょうか。### 第二章|人生を“準備期間”にしてしまうプログラム私たちの多くは、無意識のうちに次のような人生のレールに乗せられています。 **学生時代:より良い大学に入るための「準備」* 大学時代:より良い会社に入るための「準備」* 社会人時代:昇進や老後のための「準備」* 老後:人生の終わりを迎えるための「準備」人生が常に何かの「準備」の連続で、「今、この瞬間を生きる」ことが後回しにされてしまう。この構造を支えているのが、「安定こそが正義」「みんなと同じが安心」といった、思考停止を促す“プログラム”です。このプログラムは、私たちの感性を少しずつ麻痺させ、構造への疑問を抱かせないように作用します。**### 第三章|思考のOSを更新する「言語の再設計」社会のプログラムから抜け出し、自分自身の思考を取り戻す第一歩は、言葉を意識的に変えることです。固定観念を強化する言葉を、私は「毒語」と呼んでいます。この毒語を、本質を捉えた「対抗語彙」に置き換えることで、世界の見え方は大きく変わります。| 毒語(思考停止を招く言葉) | 対抗語彙(本質を捉える言葉) | 置き換えの狙い || :—…
Read More