You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Postgres it is possible to specify a function as the default for generating a UUID. ( gen_random_uuid())
With /schema/snapshot this function is included.
Start an local postgres-instance (for instance with docker) docker run -p 5432:5432 --name my-database -e POSTGRES_PASSWORD=mysecretpassword -e POSTGRES_USER=postgres -d postgres:15.1
Start an empty local directus instance (Port 8555) - connected to the postgres.
I believe this shares the same fundamental issue with #12042 around "database functions being passed as string with quotes" in default value, thus causing this error to happen as @MaLub described.
Although the previous issue was technically resolved for CURRENT_TIMESTAMP (because this isn't as vendor-specific as gen_random_uuid), there may need to be a slightly more robust way of handling default values that are db functions.
azrikahar
changed the title
Error staging a schema with defaults for UUID ( postgres - gen_random_uuid() )
Error staging a schema with database functions as default value
Mar 3, 2023
Checklist
Describe the Bug
I want to transfer the schema of a Directus instance to an empty Directus instance.
For this I use the steps as described here: https://docs.directus.io/reference/system/schema.html
We use a Postgres 15.1 and Directus 9.23.1
In Postgres it is possible to specify a function as the default for generating a UUID. ( gen_random_uuid())
With
/schema/snapshot
this function is included.During the subsequent import (/
schema/diff, /schema/apply
) an invalid SQL is generated.AddOn
When executing the above SQL statement within the DB, I get a similar error.
-->> Removing the quotes solved the problem
To Reproduce
Start an local postgres-instance (for instance with docker)
docker run -p 5432:5432 --name my-database -e POSTGRES_PASSWORD=mysecretpassword -e POSTGRES_USER=postgres -d postgres:15.1
Start an empty local directus instance (Port 8555) - connected to the postgres.
Import the attached snapshot response as described here https://docs.directus.io/reference/system/schema.html
(First
/schema/diff
and afterwards the result/schema/apply
)schema-snapshot-response.json.zip
Hosting Strategy
Self-Hosted (Docker Image)
The text was updated successfully, but these errors were encountered: