© 2026 Hedgehog Software, LLC
Twitter
GitHub
Discord
System
Light
Dark
More
Communities
Docs
About
Terms
Privacy
Search
Star
Feedback
Setup for Free
S
Supabase
•
3y ago
•
8 replies
Tobi
Is it possible to use a json file to seed a supabase postgres database?
I want to use a json file as single source of truth for my database seeds and my end
-to
-end tests
.
The following code works
:
WITH
notification
_json
(doc
) AS
(
VALUES
(
'
[
{
"sender
"
:
"42e58ca1
-2eb8
-4651
-93c2
-cefba2e32f42
"
,
"receiver
"
:
"f8b028b8
-231b
-4c80
-abf2
-7ca787fe686f
"
,
"type
_of
_notification
"
:
"follow
_from
_user
"
,
"read
_by
_receiver
"
:
"FALSE
"
}
]
'
:
:json
)
)
INSERT
INTO
authenticated
_access
.notifications
_by
_user
(sender
,
receiver
,
type
_of
_notification
,
read
_by
_receiver
)
SELECT
n
.sender
,
n
.receiver
,
n
.type
_of
_notification
,
n
.read
_by
_receiver
FROM
notification
_json l
CROSS JOIN LATERAL JSON
_POPULATE
_RECORDSET
(
N
U
L
L
:
:authenticated
_access
.notifications
_by
_user
,
doc
) AS n
;
But if I try to load the JSON from a separate file with
PG_READ_FILE('./notifications.json')
PG_READ_FILE('./notifications.json')
then the code fails with the error
:
ERROR
: could not open file
"notifications
.json
" for reading
: No such file or directory
(SQLSTATE 58P01
)
While this means
, that the file does not exist
, I checked it and the file does exist and the directory structure looks like this
:
supabase
- migrations
- seed
.sql
- notifications
.json
The following code does not work
:
WITH
notification
_json
(doc
) AS
(
VALUES
(
(
SELECT PG
_READ
_FILE
(
'
.
/notifications
.json
'
)
)
:
:json
)
)
What is wrong here
? Is it possible to use a json file in the supabase seed process
?
Supabase
Join
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816
Members
View on Discord
Resources
ModelContextProtocol
ModelContextProtocol
MCP Server
Was this page helpful?
Yes
No
Similar Threads
Recent Announcements
Similar Threads
Is it possible to use plrust to create Postgres function in Supabase?
S
Supabase / help-and-questions
3y ago
Is it possible to use an existing database ?
S
Supabase / help-and-questions
4y ago
Is it possible to use Supabase CLI while offline?
S
Supabase / help-and-questions
3mo ago
Is it possible to use spatial queries in supabase-js?
S
Supabase / help-and-questions
13mo ago