4 months ago
Can't seem to find a way to enable this extension, why is that?
Pinned Solution
3 months ago
Arlght! Here's a fully functional template that should be a 1-click deploy of the Supabase PostgreSQL image
It even works with the Railway UI for PostgreSQL which is sweet so you can browse your tables, execute queries, and view extenions all within Railway
There was an existing template but it had a 100% deploy rate on recent deploys which tells me it wasn't working very well ha.
17 Replies
4 months ago
Hey there! We've found the following might help you get unblocked faster:
If you find the answer from one of these, please let us know by solving the thread!
4 months ago
Based on the Railway documentation, you should be able to enable the pg_audit extension on your PostgreSQL database with the extensions.
Using the Extensions Tab
Railway provides an Extensions tab for PostgreSQL that allows you to manage extensions. You can view, install, and uninstall extensions that are available in the Postgres image directly through this interface.
Navigate to your PostgreSQL database in Railway
Open the Extensions tab
Look for
pg_auditin the available extensions listInstall it through the UI
If pg_audit isn't listed
For some reason my If pg_audit is not available in the Extensions tab, you might need to make your own PostgreSQL dockerfile and deploy it that way. You would need to:
1. Fork the baseline railway postgres image and add pg_audit to your custom image
2. Deploy your modified version using that custom image
For more details:
- Railway PostgreSQL documentation: https://docs.railway.com/guides/postgresql
- Database View guide: https://docs.railway.com/guides/database-view
4 months ago
so then you would lose any auto update features of railway?:( sucks that they don't have this extension.
so then you would lose any auto update features of railway?:( sucks that they don't have this extension.
4 months ago
You can always use a different PostgreSQL database maintained by someone else. The Supbase PostgreSQL image has pg_audit included by default and seems well maintained.
If you:
setup a new blank service
set the image to
supabase/postgres(see their GitHub here)set the environment variables for username, password, database, host, etc
setup auto-updates for the service in service settings
create/mount a volume to the service at the data path (
/var/lib/postgresql/data)
You should get a brand-new PostgreSQL database with a whole bunch of extensions enabled, including pg_audit.
The issue is that pg_audit isn't a standard PostgreSQL extension and as far as I can tell it requires custom binaries be downloaded and moved around inside of the actual postgresql folder; that's not possible (or at least not reproducible) with the baseline PostgreSQL image Railway uses.
4 months ago
this looks promising... trying to set it up, but what am I supposed to set as the host?
this looks promising... trying to set it up, but what am I supposed to set as the host?
4 months ago
You should be good to set the host as 0.0.0.0
This will listen on all interfaces which should be fine on railway as you have to explicitly expose the service via a TCP proxy anyways.
All the standard postgresql environment variables should apply as the image is just based on the same postgresql base image railway uses by default.
4 months ago
Hello guys,
If you want to run PostgreSQL on Railway with pg_audit enabled, the easiest and fully working setup is to use the official Supabase Postgres image, which already bundles pgaudit and dozens of other extensions.
1. Use a real Supabase tag (NOT latest)
latest does not exist for this image, so it gives manifest unknown.
Use a fixed version like:
supabase/postgres:17.6.1.044
This works on Railway (Postgres 15.x tags are also available).
2. Railway Environment Variables
Add these in Service → Variables:
POSTGRES_PASSWORD=securepass
PGDATA=/var/lib/postgresql/data/pgdata
(PGDATA avoids mount ownership problems.)
Optional:
POSTGRES_USER=postgres
POSTGRES_DB=postgres
3. Railway Volume
Add a volume with:
Mount Path:
/var/lib/postgresql/data
This is where the image expects to store its data.
4. (Only if you get ownership errors)
Use this tiny Dockerfile and deploy it instead:
FROM supabase/postgres:17.6.1.044
USER root
RUN mkdir -p /var/lib/postgresql/data \
&& chown -R postgres:postgres /var/lib/postgresql
USER postgres
This clears all FATAL: data directory has wrong ownership issues.
5. Verify pg_audit
Connect using Railway’s connection info and run:
SELECT * FROM pg_available_extensions WHERE name = 'pgaudit';
CREATE EXTENSION IF NOT EXISTS pgaudit;
SELECT * FROM pg_extension WHERE extname = 'pgaudit';
If it shows up, your image includes pgaudit (Supabase images do).
I hope this helps you get a fully working PostgreSQL instance on Railway with pg_audit enabled, using a supported Supabase Postgres build with persistent storage and no initialization or ownership errors.
4 months ago
yeah I'm running into this ownership error, I even tried the railway provided supabase template and it showed the same error. Why is that? How do I use the tiny Dockerfile to update it?
4 months ago
just wanted to check in on fixing that container issue:
1 Do you feel comfortable with GitHub for deploying a custom Dockerfile to Railway? (It's pretty straightforward)
2 Would a step-by-step guide for tweaking the Railway template to include the Dockerfile fix be helpful?
3 Are you looking to preserve your current database data, or would starting fresh be OK if needed to sort out those ownership problems?
4 months ago
yeah I could but not preferred
absolutely
no its fine, our real data is still on aws and thats what I wanna migrate.
yeah I could but not preferredabsolutelyno its fine, our real data is still on aws and thats what I wanna migrate.
3 months ago
Alright; I made a template for the Supabase/PostgreSQL image. I also ran into the ownserhip issue and found a fix for it on S.O
Will post here soon. Just validating it.
yeah I could but not preferredabsolutelyno its fine, our real data is still on aws and thats what I wanna migrate.
3 months ago
Arlght! Here's a fully functional template that should be a 1-click deploy of the Supabase PostgreSQL image
It even works with the Railway UI for PostgreSQL which is sweet so you can browse your tables, execute queries, and view extenions all within Railway
There was an existing template but it had a 100% deploy rate on recent deploys which tells me it wasn't working very well ha.
3 months ago
You rock!!! Thanks buddy!
3 months ago
DAMMIT, now this build doesn't have uuid-ossp extension:(
Status changed to Solved brody • 4 months ago
