toluaina / pgsync

Postgres to Elasticsearch/OpenSearch sync
https://pgsync.com
MIT License
1.16k stars 181 forks source link

Inconsistent relationship behavior #373

Open jpughcs opened 1 year ago

jpughcs commented 1 year ago

I am only experiencing issues with the former, but I am including the full message here by @lehuuthien2 below:

    i don't know if my problem is same as above, but i also have 3 tier relationship. You treat the middle tier (train_stations) like an pivot table, but it's a normal table and has subdata as the 3rd tier (train_station_floors) (3rd tier may or may not have data).

Problems:

  • If there is no data in the 3rd tier, the 2nd tier will not be indexed even though it has data
  • When the 3rd tier changes (insert, update,...) nothing happens, and I have to update the 2nd tier to sync the data
    "table": "railway_assets",
    "schema": "public",
    "columns": [
    "id",
    "company_id",
    "area_id",
    "name",
    "milepost",
    "image"
    ],
    "children": [
    {
        "table": "train_stations",
        "label": "train_station",
        "schema": "public",
        "columns": [
            "id",
            "railway_asset_id",
            "type",
            "area",
        ],
        "relationship": {
            "variant": "object",
            "type": "one_to_one",
            "foreign_key": {
                "child": [
                    "railway_asset_id"
                ],
                "parent": [
                    "id"
                ]
            }
        },
        "children": [
            {
                "table": "train_station_floors",
                "label": "train_station_floors",
                "relationship": {
                    "variant": "object",
                    "type": "one_to_many",
                    "foreign_key": {
                        "child": [
                            "train_station_id"
                        ],
                        "parent": [
                            "id"
                        ]
                    }
                }
            }
        ]
    }
    ]

    Originally posted by @lehuuthien2 in https://github.com/toluaina/pgsync/issues/199#issuecomment-1059002314

toluaina commented 1 year ago

Hi, Sorry for the delay. This has been addressed in the main branch. Can you try this out, please?

jpughcs commented 1 year ago

This appears to be resolved