Comments (8)
Can you please post your database schema here. Maybe just the product and category table definition.
from pgsync.
Sharing the SQL statements that were used to create the tables.
CREATE TABLE public.product (
id bigint NOT NULL,
name public.citext NOT NULL,
created_date timestamp with time zone DEFAULT now() NOT NULL,
category_id bigint NOT NULL,
brand_id bigint,
hsn bigint DEFAULT 0 NOT NULL,
active boolean DEFAULT true NOT NULL,
description text
);
ALTER TABLE ONLY public.product
ADD CONSTRAINT product_brand_id_fkey FOREIGN KEY (brand_id) REFERENCES public.category(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
ALTER TABLE ONLY public.product
ADD CONSTRAINT product_category_id_fkey FOREIGN KEY (category_id) REFERENCES public.category(id) ON UPDATE RESTRICT ON DELETE RESTRICT;
CREATE TABLE public.category (
id bigint NOT NULL,
name public.citext NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
parent_id bigint,
image_url text,
type text DEFAULT 'CATEGORY'::text NOT NULL,
description text
);
from pgsync.
I think your category table is missing a unique constraint. I don't want to assume here.
Can you provide the schema so I can recreate the tables? Possibly the entire schema
Your existing schema assuming it has a unique constraint works ok.
from pgsync.
I have an unique constraint, rather two on that table.
ALTER TABLE ONLY public.category
ADD CONSTRAINT category_name_key UNIQUE (name);
ALTER TABLE ONLY public.category
ADD CONSTRAINT category_name_type_key UNIQUE (name, type);
ALTER TABLE ONLY public.category
ADD CONSTRAINT category_pkey PRIMARY KEY (id);
Sorry that these were missed.
from pgsync.
Can you send the full database schema?
I'm simply unable to reproduce your scenario. The category is not null when I do this so maybe I'm still missing something in your full schema.
pg_dump -d <dbname> -s
from pgsync.
https://gist.github.com/arvindkhadri/e3afec66793e6a74ad00c463ca25cadd That has the complete schema.
from pgsync.
So I've created an s.sql from this db schema
psql -d mydb < s.sql
added some records
INSERT INTO category (id, name, parent_id, image_url, type, description) VALUES (1, 'cat_1', 1, 'http://foo1.bar', 'type_x', 'description 1');
INSERT INTO category (id, name, parent_id, image_url, type, description) VALUES (2, 'cat_2', 2, 'http://foo2.bar', 'type_y', 'description 2');
INSERT INTO category (id, name, parent_id, image_url, type, description) VALUES (3, 'cat_3', 3, 'http://foo3.bar', 'type_z', 'description 3');
INSERT INTO product (id, name, category_id, brand_id, hsn, active, description) VALUES (1, 'product_1', 1, 1, 123, true, 'product description 1');
INSERT INTO product (id, name, category_id, brand_id, hsn, active, description) VALUES (2, 'product_2', 2, 2, 456, false, 'product description 2');
INSERT INTO product (id, name, category_id, brand_id, hsn, active, description) VALUES (3, 'product_3', 3, 3, 789, true, 'product description 3');
pgsync -c s.json
and I get this doc data
are you sure there are related category data for those products in your database?
from pgsync.
Closing as no reply on this.
from pgsync.
Related Issues (20)
- Invalid schema in parent-child relation HOT 1
- Creating new Elastic documents for every change event instead of overwriting previous elastic document
- Checkpoint file not found error HOT 2
- Inserting new Data in the child table not reflecting in elasticsearch
- Best practice on blue/green deploy and slot clean up
- unexpected keyword argument 'use_ssl' for ELASTICSEARCH_AWS_HOSTED HOT 1
- Running PGSync strictly as WAL consumer HOT 1
- Python Vulnerabilities HOT 1
- Do Table Migrations Trigger Full Re-Index?
- `USE_ASYNC` Flag Only Observes 1 Index HOT 1
- Error when running with schema HOT 1
- xmin error on view HOT 4
- different pks on base table of materialized view
- High Memory and CPU Overload on VPS During Bulk Updates with Nested Relations HOT 1
- Retain Plugin Order As Defined in JSON HOT 1
- Redis bulk issue #2 HOT 2
- Sync issue on child tables HOT 5
- Syncing Speed
- TypeError in PGSync: Incorrect List Indexing During Primary Key Update
- Schema with Nested Translation Data Sync from PostgreSQL to Elasticsearch
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pgsync.