Skip to main content

Migrate from Supabase to NaijaBase

NaijaBase is a drop-in replacement for Supabase. Your existing code works without changes.

Why migrate?โ€‹

  • ๐Ÿ‡ณ๐Ÿ‡ฌ Data stored in Nigeria โ€” NDPA 2023 compliant
  • โ‚ฆ Pay in Naira โ€” no forex risk or dollar billing
  • ๐Ÿฆ Required for CBN-regulated fintechs and Nigerian data residency
  • ๐Ÿ“ž Local support in WAT timezone (UTC+1)

What's compatibleโ€‹

FeatureStatus
auth.uid(), auth.role(), auth.email()โœ… Full support
auth.users tableโœ… Same schema
Row Level Security (RLS) policiesโœ… Full support
PostgreSQL functions and triggersโœ… Full support
CREATE EXTENSIONโœ… Supported
storage schemaโœ… Same schema
extensions schemaโœ… Available
Realtime subscriptions๐Ÿ”œ Coming soon

Step 1 โ€” Export your Supabase schemaโ€‹

In the Supabase dashboard go to Settings โ†’ Database โ†’ Database backups, or use pg_dump:

pg_dump --schema-only \
"postgresql://postgres:[password]@db.[ref].supabase.co:5432/postgres" \
> my_schema.sql

Step 2 โ€” Create a NaijaBase projectโ€‹

Go to app.naijabase.dev โ†’ New Project.

Step 3 โ€” Run your schemaโ€‹

Open the Database tab โ†’ SQL Editor. Paste your schema SQL and click Run (or press Ctrl+Enter).

auth.uid(), auth.users, and RLS policies all work exactly the same โ€” no changes needed.

Step 4 โ€” Export your dataโ€‹

pg_dump --data-only \
"postgresql://postgres:[password]@db.[ref].supabase.co:5432/postgres" \
> my_data.sql

Step 5 โ€” Import your dataโ€‹

Paste the data SQL into the NaijaBase SQL Editor and run it.

For large datasets, connect directly with psql using the connection string from the Database tab:

psql "postgresql://[user]:[password]@102.223.38.91:5432/[database]" \
< my_data.sql

Step 6 โ€” Update your connection stringโ€‹

// Before (Supabase)
const client = createClient(
'https://xxx.supabase.co',
'your-anon-key'
)

// After (NaijaBase โ€” same code, Nigerian servers)
const client = createClient(
'https://api.naijabase.dev/v1/YOUR_PROJECT_ID',
'your-naijabase-anon-key'
)

Your API key is on the API tab of your project dashboard.

RLS exampleโ€‹

RLS policies using auth.uid() work identically on NaijaBase:

-- This Supabase policy works unchanged on NaijaBase
CREATE TABLE posts (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
user_id UUID DEFAULT auth.uid(),
content TEXT
);

ALTER TABLE posts ENABLE ROW LEVEL SECURITY;

CREATE POLICY "users see own posts" ON posts
USING (user_id = auth.uid());

CREATE POLICY "users insert own posts" ON posts
FOR INSERT WITH CHECK (user_id = auth.uid());

Common Migration Issuesโ€‹

Role errors: "role anon does not exist"โ€‹

NaijaBase automatically creates Supabase-compatible roles (anon, authenticated, service_role) in every project database. If you see this error on an older project, go to your project Settings tab and click Initialize Supabase roles.

Enum casting errorsโ€‹

If you see: operator does not exist: my_enum = text

Cast your enum column to text for string comparisons:

-- Instead of:
WHERE status = 'active'

-- Use:
WHERE status::TEXT = 'active'
-- or use the enum type directly:
WHERE status = 'active'::my_enum_type

Function return type conflictsโ€‹

If you see: cannot change return type of existing function

Drop and recreate the function:

DROP FUNCTION IF EXISTS my_function CASCADE;
CREATE OR REPLACE FUNCTION my_function() ...

NaijaBase's SQL editor automatically handles this for you in batch mode โ€” multi-statement scripts retry function conflicts with an automatic DROP.

Need help migrating?โ€‹

Email ofatokun@telecitytech.com โ€” we offer free migration assistance for Business and Compliance Pro customers.