pgsync icon indicating copy to clipboard operation
pgsync copied to clipboard

Relationship not present on

Open askatmaster opened this issue 3 years ago • 3 comments

PGSync version: 2.3.2 Postgres version: docker image postgis/postgis:latest Elasticsearch version: 8.4.3 Redis version: docker image redis:alpine Python version: docker image python:3.10.6 Problem Description: I'm trying to get the default book and author tables to sync via pgsync in doker-compose. Here is my docker compose: image

HERE IS MY schema.json image

HERE IS MY PgsyncDockerfile image

HERE IS MY entrypoint.sh image

HERE IS MY database image

All services except pgsync start and work correctly. Please help, I can't solve this problem

Error Message (if any):

wait-for-it: waiting 60 seconds for database:5432
wait-for-it: database:5432 is available after 0 seconds
wait-for-it: waiting 60 seconds for redis:6379
wait-for-it: redis:6379 is available after 0 seconds
wait-for-it: waiting 60 seconds for elasticsearch:9200
wait-for-it: elasticsearch:9200 is available after 0 seconds
/usr/local/lib/python3.10/site-packages/pgsync/base.py:170: SAWarning: Did not recognize type 'geometry' of column 'location'
  metadata.reflect(self.engine, views=True)
Traceback (most recent call last):
  File "/usr/local/bin/bootstrap", line 70, in <module>
    main()
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/bin/bootstrap", line 59, in main
    sync: Sync = Sync(
  File "/usr/local/lib/python3.10/site-packages/pgsync/sync.py", line 107, in __init__
    self.validate(repl_slots=repl_slots)
  File "/usr/local/lib/python3.10/site-packages/pgsync/sync.py", line 186, in validate
    self.root: Node = self.tree.build(self.nodes)
  File "/usr/local/lib/python3.10/site-packages/pgsync/node.py", line 295, in build
    node.add_child(self.build(child))
  File "/usr/local/lib/python3.10/site-packages/pgsync/node.py", line 224, in add_child
    raise RelationshipError(
pgsync.exc.RelationshipError: 'Relationship not present on "public.author"'
/usr/local/lib/python3.10/site-packages/pgsync/base.py:170: SAWarning: Did not recognize type 'geometry' of column 'location'
  metadata.reflect(self.engine, views=True)
Traceback (most recent call last):
  File "/usr/local/bin/pgsync", line 7, in <module>
    sync.main()
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/pgsync/sync.py", line 1410, in main
    sync: Sync = Sync(document, verbose=verbose, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/pgsync/sync.py", line 107, in __init__
    self.validate(repl_slots=repl_slots)
  File "/usr/local/lib/python3.10/site-packages/pgsync/sync.py", line 186, in validate
    self.root: Node = self.tree.build(self.nodes)
  File "/usr/local/lib/python3.10/site-packages/pgsync/node.py", line 295, in build
    node.add_child(self.build(child))
  File "/usr/local/lib/python3.10/site-packages/pgsync/node.py", line 224, in add_child
 0:00:00.244743 (0.24 sec)
    raise RelationshipError(
pgsync.exc.RelationshipError: 'Relationship not present on "public.author"'

askatmaster avatar Oct 11 '22 18:10 askatmaster

  • It seems you don't have a relationship between book and author in your database schema.
  • You must always have a relationship between a parent and a child and this can be through a surrogate table.
  • So it looks like your schema.json is incomplete.

toluaina avatar Oct 18 '22 19:10 toluaina

The screenshots provided show which tables I create with which links. Tables have relationships. Why is the chart incomplete? please give me the complete diagram.

askatmaster avatar Oct 31 '22 06:10 askatmaster

I think what he meant was to add relationship tag in your schema.json. Here is the doc

imcyee avatar Nov 11 '22 04:11 imcyee