point-source / supabase-tenant-rbac

A template for implementing basic RBAC for a multi-tenant supabase project
BSD 2-Clause "Simplified" License
315 stars 24 forks source link

Upgrading to 4.0.0 fails on Github Actions but works locally #22

Open ScissorHill opened 4 months ago

ScissorHill commented 4 months ago

I've followed this guide for setting up a CI/CD pipeline. I have a production and staging instance running for a while now. However, RBAC is on version 0.0.2. I'd like to upgrade to 4.0.0.

I have a migration file with the following lines in it:

DROP EXTENSION "pointsource-supabase_rbac";
CREATE EXTENSION "pointsource-supabase_rbac" VERSION '4.0.0';

When I do supabase db reset on my local machine, I get RBAC 4.0.0 running properly. But when I push this to staging, I get the following error on Github Actions:

ERROR: extension "pointsource-supabase_rbac" has no installation script nor update path for version "4.0.0" (SQLSTATE 22023)

Any suggestions on how this could be resolved?

ScissorHill commented 4 months ago

Update: A bit of trial and error got it working.

Any attempts to install 4.0.0 on the remote instance lead to the following error: ERROR: function moddatetime() does not exist (SQLSTATE 42883) Not sure, but this could be the root of the previous error.

It looks like previous versions expected moddatetime to be installed with the schema extensions but 4.0.0 expects it with the public schema.

The working migration file, edited manually (the diff didn't work for me):

DROP EXTENSION IF  EXISTS "pointsource-supabase_rbac";
DROP EXTENSION IF  EXISTS "moddatetime";
CREATE EXTENSION IF NOT EXISTS moddatetime
    SCHEMA "public";
select dbdev.install('pointsource-supabase_rbac');
create extension "pointsource-supabase_rbac"
    version '4.0.0';