Skip to content

Schema is not refreshed when child is inserted, but FK doesnt exist #574

@rutkowskib

Description

@rutkowskib

PGSync version:
3.2.0

Postgres version:
14.12

Elasticsearch/OpenSearch version:
8.15.0

Redis version:
6.2

Python version:
3.10

Problem Description:
Hi,

I have two tables that are parent and child.
They are connected manually by defining foreign_key instead of having FK in SQL.
pgsync schema looks like this:

{
    "label": "books",
    "table": "book",
    "columns": ["isbn", "title", "description"],
    "children": [
        {
            "label": "reviews",
            "table": "review",
            "columns": ["id", "text"],
            "relationship": {
                "variant": "object",
                "type": "one_to_many",
                "foreign_key": {
                    "child": [
                        "book_isbn"
                    ],
                    "parent": [
                        "isbn"
                    ]
                }
            }
        }
    ]
}

We have noticed that whenever child is inserted parent document is not updated.
In our prod environment we cant add FK because tables are in different schemas and we dont want to create dependencies between them.

I have managed to write failing test, but I lack knowledge how to fix that issue. If you could point me in correct direction, I might be able to fix that. I am going to raise merge request connected to that issue that contains failing test.

Thanks for your help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions