#Issue on Connecting Postgres

1 messages · Page 1 of 1 (latest)

outer warren
#

Hi @eternal spoke, thanks for sharing the issue we’re on it.

cunning berry
#

Hi @eternal spoke ,first of all, I suggest you double-check your credentials and try again. If you have started permify and postgres in Docker, you need to replace "localhost" with "host.docker.internal" to make it work.

eternal spoke
#

Thanks fixed it needed to pass host.docker.internal
postgres://admin:admin@host.docker.internal:5432/test

eternal spoke
#

Hi one more issue I create database on psql and permify on k8s also get connected but the migration did not ran on the database do I need to any flag, when I write in schema getting this error

{
    "code": 13,
    "message": "ERROR: relation \"schema_definitions\" does not exist (SQLSTATE 42P01)",
    "details": []
}```
shy wadi
#

Hi @eternal spoke , thanks for sharing the issue I'am on it.

#

You can Check this pull request https://github.com/Permify/permify/pull/297

and you can use this command with your credentials

permify migrate up  --database-engine=postgres 
--databaseuri=postgres://postgres:secret@localhost:5432/permify
#

This command migrate all Tables ın permify migration files

#

if you have any problem again you can tag me again Happy Coding gophercool

eternal spoke
#

@shy wadi how can I run this command with kubernetes yaml file?

shy wadi
#

for example

apiVersion: batch/v1
kind: Job
metadata:
  name: permify-migrate
spec:
  template:
    spec:
      containers:
      - name: permify-migrate
        image: <your-docker-image>
        command: ["permify"]
        args: ["migrate", "up", "--database-engine=postgres", "--databaseuri=postgres://postgres:secret@localhost:5432/permify"]
      restartPolicy: Never
  backoffLimit: 4
#

if you can access Postgresl from outside, you can log in to the permify pod or from your local yourself and run this command once, it will be enough to migrate once anyway

eternal spoke
#

But when I was testing locally it created the tables on my local postgres but when using aws RDS it was unable to create the tables will this work ?

shy wadi
#

if you use Amazon RDS for PostgreSQL , yes

#

can you check if the aws rds information is correct or if there may be an authorization error

#

from RDS Configs?

eternal spoke
#

I am using super user for rds

#

yes it is connected to the DB I think if permify find invalid info regarding DB it will not expose the ports of http and grpc

#

also this command will work with the existing docker ?

shy wadi
#

when an instance is opened on onegin mongo, there are network ip limits at first, even if you are a super user, do you check the network interface settings on the rds part?

#

yes this command is active and you can use

eternal spoke
shy wadi
#

you can check your security groups from aws

#

like this

eternal spoke
#

rpc error: code = Unknown desc = Manifest generation error (cached): rpc error: code = FailedPrecondition desc = Failed to unmarshal "permify-deployment.yaml": failed to unmarshal manifest: error converting YAML to JSON: yaml: line 24: did not find expected key

          name: permify
          command: [ "permify" ]
          args: [ "migrate", "up", "--database-engine=postgres", "--databaseuri=$(DB_URI)" ]
            - "serve"
            - "--database-engine=postgres"
            - "--database-uri=$(DB_URI)"
            - "--database-max-open-connections=20"
            - "--authn-enabled"
            - "--authn-method=preshared"
            - "--authn-preshared-keys=$(PRE_SHARED_KEYS)"
          env:
            - name: DB_URI
              valueFrom:
                secretKeyRef:
                  name: permify-dev-secrets
                  key: DB_URI
            - name: PRE_SHARED_KEYS
              valueFrom:
                secretKeyRef:
                  name: permify-dev-secrets
                  key: PRE_SHARED_KEYS```
#

getting this error when adding migrate cmd

shy wadi
#

migrate is not a service
when you use the migrate command, the service does not start, the code stops running

eternal spoke
#

My bad I forgot its a job

shy wadi
#

first you run migrate and after run the permify serve

shy wadi
#

you can exacute migrate job from your computer first time

eternal spoke
#

I need to run this command from the docker terminal right?

#

If run from locally

shy wadi
#

are you use brew?

#

or you can clone repo from github

#

and run this command in repo directory like this

go run cmd/permify/permify.go migrate up  --database-engine=postgres 
--databaseuri=postgres://postgres:secret@localhost:5432/permify
#

with your pg creds

shy wadi
#

@eternal spoke is this okey?

#

are you tested?

eternal spoke
#

@shy wadi getting this error

shy wadi
#

Okey

#

Do you use Brew?

eternal spoke
#

yes

#

but I was doing it on jump server

#

on dev enviroment

shy wadi
#

you can use migrate command one time in your local computer

eternal spoke
#

db is not accessible from local

#

I can manually run the migration on the DB right no issue in that ?

shy wadi