#Bootstrap Permify with Postgres
1 messages ยท Page 1 of 1 (latest)
Hello @fluid shuttle ,To bootstrap Permify with Postgres:
- Create a database in your Postgres container.
- Set up a user with a password and grant them access to the database.
- Update the
config.ymlfile with the correct URI format:postgres://user:password@host:5432/db_name.
Permify should then use the provided URI to connect to and interact with the specified Postgres database.
Thanks @dark bobcat! But I wonder how I can get Permify to bootstrap the database, after running "permify serve" there are no tables in the database. And when creating a Permify schema in Go I get the following error: "ERROR: relation "schema_definitions" does not exist (SQLSTATE 42P01)"
database:
engine: postgres
uri: postgres://user:password@host:5432/db_name
auto_migrate: true
You should set the auto_migrate option to true
Is it work @fluid shuttle ?
Thanks, it worked in the end! I had to grant the user superuser privileges though, it was not enough to grant all. (I think, I just brute forced my way through ๐ Initially I got this error: permify migrate up --database-engine postgres --database-uri postgres://permify:permify@localhost:5432/permify
migration failed: up error ERROR: permission denied for schema public (SQLSTATE 42501)
I'm glad you resolved it. Superuser rights in Postgres have their complexities. We're here to help; what are your expectations?
So I was able to create a schema and read and write some relationships and do some permission checks with Go. So far it is looking good ...
Great! If you encounter any problems feel free to write to us
Hey, I'm also encountering some issue while setting up with postgres
after running migrate up
I've received migration failed: up error internal/storage/postgres/migrations directory does not exist
im using latest docker image
BTW I've also created a issue on the node-js client - it has old code published ๐
Hello @lusty stone ,
Please bootstrap Permify using the auto-migrate flag for now. We will resolve this issue and the problem with the Permify node in the next release.
hey @dark bobcat when using the auto migrate flag nothing happens, and when want to try to write the schema I'm getting SQL errror about not existing table
it only works with in memory db
hi @lusty stone , which version of Postgres are you using?
15.3
weird thing is that it does not inform me on boot that the migrations failed
do I need to change the log level?
Can you share the entire run command with me if you're using flags, or if you're using a config, can you share the config file without any sensitive information?
sure
I'm using docker compose
image: "ghcr.io/permify/permify:latest"
command: "serve --config /config/config.yaml"
restart: "always"
volumes:
- ./config/permify:/config
ports:
- "3476:3476"
- "3478:3478"
depends_on:
- "db"
config.yaml
engine: postgres
uri: postgres://postgres:postgres@db:5432/permify?sslmode=disable
auto_migrate: true
max_open_connections: 20
max_idle_connections: 1
max_connection_lifetime: 300s
max_connection_idle_time: 60s
Everything looks normal. Can you share the Permify logs with me?
no, it's not necessary
safc-registry-permify-1 |
safc-registry-permify-1 | โโโโโโโ โโโโโโโโโโโโโโโ โโโโ โโโโโโโโโโโโโโโโโโ โโโ
safc-registry-permify-1 | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโ
safc-registry-permify-1 | โโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโ
safc-registry-permify-1 | โโโโโโโ โโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโ
safc-registry-permify-1 | โโโ โโโโโโโโโโโ โโโโโโ โโโ โโโโโโโโโ โโโ
safc-registry-permify-1 | โโโ โโโโโโโโโโโ โโโโโโ โโโโโโโโโ โโโ
safc-registry-permify-1 | _______________________________________________________
safc-registry-permify-1 | Fine-grained Authorization System v0.5.3
safc-registry-permify-1 | {"level":"info","time":"2023-10-04T06:41:45Z","caller":"/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:940","message":"๐ starting permify service..."}
safc-registry-permify-1 | {"level":"info","time":"2023-10-04T06:41:46Z","caller":"/home/runner/work/permify/permify/pkg/cmd/serve.go:305","message":"๐ grpc server successfully started: 3478"}
safc-registry-permify-1 | {"level":"info","time":"2023-10-04T06:41:46Z","caller":"/home/runner/work/permify/permify/pkg/cmd/serve.go:305","message":"๐ http server successfully started: 3476"}
safc-registry-permify-1 | {"level":"info","time":"2023-10-04T06:41:56Z","caller":"/home/runner/work/permify/permify/internal/servers/schemaServer.go:70","message":"ERROR: relation \"schema_definitions\" does not exist (SQLSTATE 42P01)"}
is there any table created in the database?
nope
does permify needs some special PRIVILEGES on postgres side?
let me check something I think it's my mistake
yeah no, I've tried to change the psql uri but it was erroring after change so it should have access to db
with the config I've sent you
but it's not running migrations for some reason
what are the privileges of the user you are currently connected with? can you try to elevate them?
CREATE USER $database;
ALTER USER $database WITH SUPERUSER;
CREATE DATABASE $database;
GRANT ALL PRIVILEGES ON DATABASE $database TO $database;
we have a simple script to create db on official postgres images
it's just for dev purposes
really an interesting error, I will do my own tests and get back to you
you are welcome. I will try to get back as soon as possible
Hello @lusty stone , we've identified the source of the error and will release a new version in a few hours. I will notify you from here.
we've released a preview at ghcr.io/permify/permify-beta:v0.5.4-d866c3e Could you please test it?
sure
safc-registry-permify-1 | โโโโโโโ โโโโโโโโโโโโโโโ โโโโ โโโโโโโโโโโโโโโโโโ โโโ
safc-registry-permify-1 | โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโ
safc-registry-permify-1 | โโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโ
safc-registry-permify-1 | โโโโโโโ โโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโ
safc-registry-permify-1 | โโโ โโโโโโโโโโโ โโโโโโ โโโ โโโโโโโโโ โโโ
safc-registry-permify-1 | โโโ โโโโโโโโโโโ โโโโโโ โโโโโโโโโ โโโ
safc-registry-permify-1 | _______________________________________________________
safc-registry-permify-1 | Fine-grained Authorization System v0.5.4
safc-registry-permify-1 | {"level":"info","time":"2023-10-05T07:57:10Z","caller":"/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:940","message":"๐ starting permify service..."}
safc-registry-permify-1 | 2023/10/05 07:57:12 OK 20230117143902_initial.sql (19.79ms)
safc-registry-permify-1 | 2023/10/05 07:57:12 OK 20230117145140_multi_tenant.sql (13.36ms)
safc-registry-permify-1 | 2023/10/05 07:57:12 OK 20230118185622_index_optimization.sql (9.51ms)
safc-registry-permify-1 | 2023/10/05 07:57:12 OK 20230729145034_attributes.sql (9.32ms)
safc-registry-permify-1 | 2023/10/05 07:57:12 goose: successfully migrated database to version: 20230729145034
safc-registry-permify-1 | {"level":"info","time":"2023-10-05T07:57:12Z","caller":"/home/runner/work/permify/permify/pkg/cmd/serve.go:305","message":"๐ grpc server successfully started: 3478"}
safc-registry-permify-1 | {"level":"info","time":"2023-10-05T07:57:12Z","caller":"/home/runner/work/permify/permify/pkg/cmd/serve.go:305","message":"๐ http server successfully started: 3476"}```
it worked ๐
thank you !
You're welcome. If you encounter any other problems feel free to reach out to us ๐
I'm just waiting for new release of the nodejs client with the Data instead Relationship endpoints
after that I'm gonna be able to fully test ๐
hi @lusty stone , we've released new version for permify-node
could you please test it?
hey @dark bobcat sure, thank you ๐
now I can see the 'Data' endpoint on the node lib, thank you ๐