#Bootstrap Permify with Postgres

1 messages ยท Page 1 of 1 (latest)

dark bobcat
#

Hello @fluid shuttle ,To bootstrap Permify with Postgres:

  1. Create a database in your Postgres container.
  2. Set up a user with a password and grant them access to the database.
  3. Update the config.yml file 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.

fluid shuttle
#

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)"

dark bobcat
#
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 ?

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)

dark bobcat
#

I'm glad you resolved it. Superuser rights in Postgres have their complexities. We're here to help; what are your expectations?

fluid shuttle
#

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 ...

dark bobcat
#

Great! If you encounter any problems feel free to write to us

lusty stone
#

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 ๐Ÿ™‚

dark bobcat
#

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.

lusty stone
#

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

dark bobcat
#

hi @lusty stone , which version of Postgres are you using?

lusty stone
#

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?

dark bobcat
#

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?

lusty stone
#

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
dark bobcat
#

Everything looks normal. Can you share the Permify logs with me?

lusty stone
#

sure

#

do I need set a specific log level?

dark bobcat
#

no, it's not necessary

lusty stone
#
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)"}
dark bobcat
#

is there any table created in the database?

lusty stone
#

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

dark bobcat
#

what are the privileges of the user you are currently connected with? can you try to elevate them?

lusty stone
#
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

dark bobcat
#

really an interesting error, I will do my own tests and get back to you

lusty stone
#

I'm going to check also on my side

#

thank you for you resposne @dark bobcat

dark bobcat
#

you are welcome. I will try to get back as soon as possible

dark bobcat
#

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.

dark bobcat
#

we've released a preview at ghcr.io/permify/permify-beta:v0.5.4-d866c3e Could you please test it?

lusty stone
#

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 !

dark bobcat
#

You're welcome. If you encounter any other problems feel free to reach out to us ๐Ÿ™‚

lusty stone
#

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 ๐Ÿ™‚

dark bobcat
#

hi @lusty stone , we've released new version for permify-node

#

could you please test it?

lusty stone
#

hey @dark bobcat sure, thank you ๐Ÿ™‚

lusty stone
#

now I can see the 'Data' endpoint on the node lib, thank you ๐Ÿ™‚