Skip to content

Error during execute custom command with two relateds tables #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gegonzalez07 opened this issue Oct 27, 2023 · 4 comments
Open

Error during execute custom command with two relateds tables #49

gegonzalez07 opened this issue Oct 27, 2023 · 4 comments

Comments

@gegonzalez07
Copy link

I have two tables, Category and Worker (with one to many relations) I could generate Category without issue, but generate Worker throw ¨violates foraign key constraint¨. How i could handle ¨category¨ foreign key in Worker table?

@faisaltheparttimecoder
Copy link
Owner

Hello @gegonzalez07 ,

Please pass the DDL for Category and Worker table.

Thanks

@gegonzalez07
Copy link
Author

gegonzalez07 commented Oct 27, 2023

Hello @gegonzalez07 ,

Please pass the DDL for Category and Worker table.

Thanks

Thank you for responding so quickly

Category table

-- ----------------------------
-- Table structure for Category
-- ----------------------------
DROP TABLE IF EXISTS "public"."Category";
CREATE TABLE "public"."Category" (
  "Id" int8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
),
  "Name" text COLLATE "pg_catalog"."default" NOT NULL,
  "CategoryParentId" int8,
  "Created" timestamptz(6) NOT NULL,
  "LastModified" timestamptz(6),
  "StatusBaseEntity" int4 NOT NULL
)
;

-- ----------------------------
-- Indexes structure for table Category
-- ----------------------------
CREATE INDEX "IX_Category_CategoryParentId" ON "public"."Category" USING btree (
  "CategoryParentId" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE UNIQUE INDEX "PK_Category" ON "public"."Category" USING btree (
  "Id" "pg_catalog"."int8_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table Category
-- ----------------------------
ALTER TABLE "public"."Category" ADD CONSTRAINT "pk_category" PRIMARY KEY ("Id");

-- ----------------------------
-- Foreign Keys structure for table Category
-- ----------------------------
ALTER TABLE "public"."Category" ADD CONSTRAINT "fk_category_category_categoryparentid" FOREIGN KEY ("CategoryParentId") REFERENCES "public"."Category" ("Id") ON DELETE NO ACTION ON UPDATE NO ACTION;

Worker table

-- ----------------------------
-- Table structure for Worker
-- ----------------------------
DROP TABLE IF EXISTS "public"."Worker";
CREATE TABLE "public"."Worker" (
  "Id" int8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
),
  "Name" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "StartDate" timestamptz(6) NOT NULL,
  "FinishDate" timestamptz(6) NOT NULL,
  "PublishingDate" timestamptz(6) NOT NULL,
  "ShortDescription" varchar(250) COLLATE "pg_catalog"."default" NOT NULL,
  "LongDescription" varchar(500) COLLATE "pg_catalog"."default" NOT NULL,
  "Price" float8 NOT NULL DEFAULT 0.0,
  "OrderPriority" int4 NOT NULL DEFAULT 1,
  "NeedId" bool NOT NULL DEFAULT false,
  "NeedSnack" bool NOT NULL DEFAULT false,
  "Payment" varchar(20) COLLATE "pg_catalog"."default" NOT NULL,
  "CategoryId" int8 NOT NULL,
  "Created" timestamptz(6) NOT NULL,
  "LastModified" timestamptz(6),
  "StatusBaseEntity" int4 NOT NULL
)
;

-- ----------------------------
-- Indexes structure for table Worker
-- ----------------------------
CREATE INDEX "IX_Worker_CategoryId" ON "public"."Worker" USING btree (
  "CategoryId" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE UNIQUE INDEX "PK_Worker" ON "public"."Worker" USING btree (
  "Id" "pg_catalog"."int8_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table Worker
-- ----------------------------
ALTER TABLE "public"."Worker" ADD CONSTRAINT "pk_Worker" PRIMARY KEY ("Id");

-- ----------------------------
-- Foreign Keys structure for table Worker
-- ----------------------------
ALTER TABLE "public"."Worker" ADD CONSTRAINT "fk_Worker_category_categoryid" FOREIGN KEY ("CategoryId") REFERENCES "public"."Category" ("Id") ON DELETE CASCADE ON UPDATE NO ACTION;

@faisaltheparttimecoder
Copy link
Owner

faisaltheparttimecoder commented Oct 31, 2023

Hello @gegonzalez07

This seems to be a bug, i.e your DDL have CamelCase columns and I guess somewhere we dont honor the camelcase.

If you look at the below debug

 % ./mock-darwin-amd64-v3.0 d -f -u testme -a localhost -q -v
DEBU[2023-10-31 10:28:57] Checking the version of the database          file="sql.go:67" 
INFO[2023-10-31 10:28:57] Version of the database: PostgreSQL 12.14 on x86_64-apple-darwin21.6.0, compiled by Apple clang version 14.0.0 (clang-1400.0.29.202), 64-bit  file="sql.go:82"
DEBU[2023-10-31 10:28:57] Checking if this a greenplum or postgres DB   file="sql.go:88"
INFO[2023-10-31 10:28:57] The flavour of postgres is: postgres          file="sql.go:97"
INFO[2023-10-31 10:28:57] The database that will be used by mock program is: postgres  file="cmd.go:82"
INFO[2023-10-31 10:28:57] Starting the program to mock full database    file="database.go:53"
INFO[2023-10-31 10:28:57] Extracting the tables in the database: postgres  file="database.go:60"
DEBU[2023-10-31 10:28:57] Extracting the tables info from the postgres database  file="sql.go:102"
DEBU[2023-10-31 10:28:57] Total number of tables to mock: 1             file="worker.go:28"
INFO[2023-10-31 10:28:57] Beginning the mocking process for the tables  file="worker.go:40"
INFO[2023-10-31 10:28:57] Extracting the columns and data type information  file="worker.go:63"
DEBU[2023-10-31 10:28:57] Extracting the column information from postgres database for table: "public"."Category"  file="sql.go:184"
INFO[2023-10-31 10:28:57] Saving all the backup files to the path: /Users/testme/mock/20231031102857  file="constraintsBackup.go:21"
DEBU[2023-10-31 10:28:57] Backing up all the constraints from the database: postgres  file="constraintsBackup.go:31"
DEBU[2023-10-31 10:28:57] Extracting the DDL of the p constraints       file="sql.go:264"
DEBU[2023-10-31 10:28:57] Extracting the DDL of the f constraints       file="sql.go:264"
DEBU[2023-10-31 10:28:57] Extracting the DDL of the u constraints       file="sql.go:264"
DEBU[2023-10-31 10:28:57] Extracting the DDL of the c constraints       file="sql.go:264"
DEBU[2023-10-31 10:28:57] Backing up all the unique indexes from the database: postgres  file="constraintsBackup.go:53"
DEBU[2023-10-31 10:28:57] Extracting the unique indexes                 file="sql.go:298"
INFO[2023-10-31 10:28:57] Total numbers of tables to mock: 1            file="worker.go:109"
DEBU[2023-10-31 10:28:57] Removing constraints for table: "public"."Category"  file="constraintsBackup.go:96"
DEBU[2023-10-31 10:28:57] Extracting constraint info for table: "public"."Category"  file="sql.go:333"
DEBU[2023-10-31 10:28:57] Building and loading mock data to the table "public"."Category"  file="worker.go:134"
INFO[2023-10-31 10:28:57] Completed loading mock data to 1 tables       file="worker.go:125"
INFO[2023-10-31 10:28:57] Found 1 violation of primary keys, if found any attempting to fix them  file="constraintsRestore.go:28"
DEBU[2023-10-31 10:28:57] Fixing the Primary / Unique Key for table "public"."Category"  file="constraintsRestore.go:51"
DEBU[2023-10-31 10:28:57] query: SELECT COUNT(*) FROM ( SELECT "id" FROM "public"."Category" GROUP BY "id" HAVING COUNT(*) > 1 ) a  file="sql.go:436"
ERRO[2023-10-31 10:28:57] Error when executing the query to extract pk violators: ERROR #42703 column "id" does not exist  file="sql.go:437"
INFO[2023-10-31 10:28:57] Found 2 violation of unique keys, if found any attempting to fix them  file="constraintsRestore.go:28"
DEBU[2023-10-31 10:28:57] Fixing the Primary / Unique Key for table "public"."Category"  file="constraintsRestore.go:51"
DEBU[2023-10-31 10:28:57] query: SELECT COUNT(*) FROM ( SELECT "id" FROM "public"."Category" GROUP BY "id" HAVING COUNT(*) > 1 ) a  file="sql.go:436"
ERRO[2023-10-31 10:28:57] Error when executing the query to extract pk violators: ERROR #42703 column "id" does not exist  file="sql.go:437"
DEBU[2023-10-31 10:28:57] Fixing the Primary / Unique Key for table "public"."Category"  file="constraintsRestore.go:51"
DEBU[2023-10-31 10:28:57] query: SELECT COUNT(*) FROM ( SELECT "id" FROM "public"."Category" GROUP BY "id" HAVING COUNT(*) > 1 ) a  file="sql.go:436"
ERRO[2023-10-31 10:28:57] Error when executing the query to extract pk violators: ERROR #42703 column "id" does not exist  file="sql.go:437"
INFO[2023-10-31 10:28:57] Found 1 violation of foreign keys, if found any attempting to fix them  file="constraintsRestore.go:28"
DEBU[2023-10-31 10:28:57] Checking / Fixing FOREIGN KEY Violation table: "public"."Category", column: "CategoryParentId", reference: "Category"("Id")  file="constraintsRestore.go:112"
DEBU[2023-10-31 10:28:58] Extracting the foreign violations for table "public"."Category" and column "Category"  file="sql.go:543"
INFO[2023-10-31 10:28:58] Attempting to recreating all the constraints  file="constraintsRestore.go:182"
INFO[2023-10-31 10:28:58] Successfully completed running the database sub command  file="cmd.go:102"
 %

The query executed is all lowercase.

query: SELECT COUNT(*) FROM ( SELECT "id" FROM "public"."Category" GROUP BY "id" HAVING COUNT(*) > 1 ) a  file="sql.go:436"

Changing the DDL id column to lower case, seems to work.

-- ----------------------------
-- Table structure for Category
-- ----------------------------
DROP TABLE IF EXISTS "public"."Category";
CREATE TABLE "public"."Category" (
  Id int8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
),
  "Name" text COLLATE "pg_catalog"."default" NOT NULL,
  "CategoryParentId" int8,
  "Created" timestamptz(6) NOT NULL,
  "LastModified" timestamptz(6),
  "StatusBaseEntity" int4 NOT NULL
)
;

-- ----------------------------
-- Indexes structure for table Category
-- ----------------------------
CREATE INDEX "IX_Category_CategoryParentId" ON "public"."Category" USING btree (
  "CategoryParentId" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE UNIQUE INDEX "PK_Category" ON "public"."Category" USING btree (
  Id "pg_catalog"."int8_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table Category
-- ----------------------------
ALTER TABLE "public"."Category" ADD CONSTRAINT "pk_category" PRIMARY KEY ("Id");

-- ----------------------------
-- Foreign Keys structure for table Category
-- ----------------------------
ALTER TABLE "public"."Category" ADD CONSTRAINT "fk_category_category_categoryparentid" FOREIGN KEY ("CategoryParentId") REFERENCES "public"."Category" (Id) ON DELETE NO ACTION ON UPDATE NO ACTION;


-- ----------------------------
-- Table structure for Worker
-- ----------------------------
DROP TABLE IF EXISTS "public"."Worker";
CREATE TABLE "public"."Worker" (
  Id int8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
),
  "Name" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "StartDate" timestamptz(6) NOT NULL,
  "FinishDate" timestamptz(6) NOT NULL,
  "PublishingDate" timestamptz(6) NOT NULL,
  "ShortDescription" varchar(250) COLLATE "pg_catalog"."default" NOT NULL,
  "LongDescription" varchar(500) COLLATE "pg_catalog"."default" NOT NULL,
  "Price" float8 NOT NULL DEFAULT 0.0,
  "OrderPriority" int4 NOT NULL DEFAULT 1,
  "NeedId" bool NOT NULL DEFAULT false,
  "NeedSnack" bool NOT NULL DEFAULT false,
  "Payment" varchar(20) COLLATE "pg_catalog"."default" NOT NULL,
  "CategoryId" int8 NOT NULL,
  "Created" timestamptz(6) NOT NULL,
  "LastModified" timestamptz(6),
  "StatusBaseEntity" int4 NOT NULL
)
;

-- ----------------------------
-- Indexes structure for table Worker
-- ----------------------------
CREATE INDEX "IX_Worker_CategoryId" ON "public"."Worker" USING btree (
  "CategoryId" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE UNIQUE INDEX "PK_Worker" ON "public"."Worker" USING btree (
  Id "pg_catalog"."int8_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table Worker
-- ----------------------------
ALTER TABLE "public"."Worker" ADD CONSTRAINT "pk_Worker" PRIMARY KEY (Id);

-- ----------------------------
-- Foreign Keys structure for table Worker
-- ----------------------------
ALTER TABLE "public"."Worker" ADD CONSTRAINT "fk_Worker_category_categoryid" FOREIGN KEY ("CategoryId") REFERENCES "public"."Category" (Id) ON DELETE CASCADE ON UPDATE NO ACTION;




 % ./mock-darwin-amd64-v3.0 d -f -u testme-a localhost -q
INFO[2023-10-31 10:43:31] Version of the database: PostgreSQL 12.14 on x86_64-apple-darwin21.6.0, compiled by Apple clang version 14.0.0 (clang-1400.0.29.202), 64-bit
INFO[2023-10-31 10:43:31] The flavour of postgres is: postgres
INFO[2023-10-31 10:43:31] The database that will be used by mock program is: postgres
INFO[2023-10-31 10:43:31] Starting the program to mock full database
INFO[2023-10-31 10:43:31] Extracting the tables in the database: postgres
INFO[2023-10-31 10:43:31] Beginning the mocking process for the tables
INFO[2023-10-31 10:43:31] Extracting the columns and data type information
Extracting column information from tables 100% [==================================================] (2/2)
INFO[2023-10-31 10:43:31] Saving all the backup files to the path: /Users/testme/mock/20231031104331
INFO[2023-10-31 10:43:31] Total numbers of tables to mock: 2
Mocking Table "public"."Worker" 100% [==================================================] (10/10)
Mocking Table "public"."Category" 100% [==================================================] (10/10)
INFO[2023-10-31 10:43:31] Completed loading mock data to 2 tables
INFO[2023-10-31 10:43:31] Found 1 violation of primary keys, if found any attempting to fix them
Fixing primary keys violation 100% [==================================================] (1/1)
INFO[2023-10-31 10:43:31] Found 4 violation of unique keys, if found any attempting to fix them
Fixing unique keys violation 100% [==================================================] (4/4)
INFO[2023-10-31 10:43:31] Found 0 violation of foreign keys, if found any attempting to fix them
INFO[2023-10-31 10:43:31] Attempting to recreating all the constraints
Recreating the constraint type "p" 100% [==================================================] (1/1)
Recreating the constraint type "u" 100% [==================================================] (4/4)
INFO[2023-10-31 10:43:32] Successfully completed running the database sub command
%

I will get that fixed. Thanks for reporting the bug

@gegonzalez07
Copy link
Author

Hello @gegonzalez07

This seems to be a bug, i.e your DDL have CamelCase columns and I guess somewhere we dont honor the camelcase.

If you look at the below debug

 % ./mock-darwin-amd64-v3.0 d -f -u testme -a localhost -q -v
DEBU[2023-10-31 10:28:57] Checking the version of the database          file="sql.go:67" 
INFO[2023-10-31 10:28:57] Version of the database: PostgreSQL 12.14 on x86_64-apple-darwin21.6.0, compiled by Apple clang version 14.0.0 (clang-1400.0.29.202), 64-bit  file="sql.go:82"
DEBU[2023-10-31 10:28:57] Checking if this a greenplum or postgres DB   file="sql.go:88"
INFO[2023-10-31 10:28:57] The flavour of postgres is: postgres          file="sql.go:97"
INFO[2023-10-31 10:28:57] The database that will be used by mock program is: postgres  file="cmd.go:82"
INFO[2023-10-31 10:28:57] Starting the program to mock full database    file="database.go:53"
INFO[2023-10-31 10:28:57] Extracting the tables in the database: postgres  file="database.go:60"
DEBU[2023-10-31 10:28:57] Extracting the tables info from the postgres database  file="sql.go:102"
DEBU[2023-10-31 10:28:57] Total number of tables to mock: 1             file="worker.go:28"
INFO[2023-10-31 10:28:57] Beginning the mocking process for the tables  file="worker.go:40"
INFO[2023-10-31 10:28:57] Extracting the columns and data type information  file="worker.go:63"
DEBU[2023-10-31 10:28:57] Extracting the column information from postgres database for table: "public"."Category"  file="sql.go:184"
INFO[2023-10-31 10:28:57] Saving all the backup files to the path: /Users/testme/mock/20231031102857  file="constraintsBackup.go:21"
DEBU[2023-10-31 10:28:57] Backing up all the constraints from the database: postgres  file="constraintsBackup.go:31"
DEBU[2023-10-31 10:28:57] Extracting the DDL of the p constraints       file="sql.go:264"
DEBU[2023-10-31 10:28:57] Extracting the DDL of the f constraints       file="sql.go:264"
DEBU[2023-10-31 10:28:57] Extracting the DDL of the u constraints       file="sql.go:264"
DEBU[2023-10-31 10:28:57] Extracting the DDL of the c constraints       file="sql.go:264"
DEBU[2023-10-31 10:28:57] Backing up all the unique indexes from the database: postgres  file="constraintsBackup.go:53"
DEBU[2023-10-31 10:28:57] Extracting the unique indexes                 file="sql.go:298"
INFO[2023-10-31 10:28:57] Total numbers of tables to mock: 1            file="worker.go:109"
DEBU[2023-10-31 10:28:57] Removing constraints for table: "public"."Category"  file="constraintsBackup.go:96"
DEBU[2023-10-31 10:28:57] Extracting constraint info for table: "public"."Category"  file="sql.go:333"
DEBU[2023-10-31 10:28:57] Building and loading mock data to the table "public"."Category"  file="worker.go:134"
INFO[2023-10-31 10:28:57] Completed loading mock data to 1 tables       file="worker.go:125"
INFO[2023-10-31 10:28:57] Found 1 violation of primary keys, if found any attempting to fix them  file="constraintsRestore.go:28"
DEBU[2023-10-31 10:28:57] Fixing the Primary / Unique Key for table "public"."Category"  file="constraintsRestore.go:51"
DEBU[2023-10-31 10:28:57] query: SELECT COUNT(*) FROM ( SELECT "id" FROM "public"."Category" GROUP BY "id" HAVING COUNT(*) > 1 ) a  file="sql.go:436"
ERRO[2023-10-31 10:28:57] Error when executing the query to extract pk violators: ERROR #42703 column "id" does not exist  file="sql.go:437"
INFO[2023-10-31 10:28:57] Found 2 violation of unique keys, if found any attempting to fix them  file="constraintsRestore.go:28"
DEBU[2023-10-31 10:28:57] Fixing the Primary / Unique Key for table "public"."Category"  file="constraintsRestore.go:51"
DEBU[2023-10-31 10:28:57] query: SELECT COUNT(*) FROM ( SELECT "id" FROM "public"."Category" GROUP BY "id" HAVING COUNT(*) > 1 ) a  file="sql.go:436"
ERRO[2023-10-31 10:28:57] Error when executing the query to extract pk violators: ERROR #42703 column "id" does not exist  file="sql.go:437"
DEBU[2023-10-31 10:28:57] Fixing the Primary / Unique Key for table "public"."Category"  file="constraintsRestore.go:51"
DEBU[2023-10-31 10:28:57] query: SELECT COUNT(*) FROM ( SELECT "id" FROM "public"."Category" GROUP BY "id" HAVING COUNT(*) > 1 ) a  file="sql.go:436"
ERRO[2023-10-31 10:28:57] Error when executing the query to extract pk violators: ERROR #42703 column "id" does not exist  file="sql.go:437"
INFO[2023-10-31 10:28:57] Found 1 violation of foreign keys, if found any attempting to fix them  file="constraintsRestore.go:28"
DEBU[2023-10-31 10:28:57] Checking / Fixing FOREIGN KEY Violation table: "public"."Category", column: "CategoryParentId", reference: "Category"("Id")  file="constraintsRestore.go:112"
DEBU[2023-10-31 10:28:58] Extracting the foreign violations for table "public"."Category" and column "Category"  file="sql.go:543"
INFO[2023-10-31 10:28:58] Attempting to recreating all the constraints  file="constraintsRestore.go:182"
INFO[2023-10-31 10:28:58] Successfully completed running the database sub command  file="cmd.go:102"
 %

The query executed is all lowercase.

query: SELECT COUNT(*) FROM ( SELECT "id" FROM "public"."Category" GROUP BY "id" HAVING COUNT(*) > 1 ) a  file="sql.go:436"

Changing the DDL id column to lower case, seems to work.

-- ----------------------------
-- Table structure for Category
-- ----------------------------
DROP TABLE IF EXISTS "public"."Category";
CREATE TABLE "public"."Category" (
  Id int8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
),
  "Name" text COLLATE "pg_catalog"."default" NOT NULL,
  "CategoryParentId" int8,
  "Created" timestamptz(6) NOT NULL,
  "LastModified" timestamptz(6),
  "StatusBaseEntity" int4 NOT NULL
)
;

-- ----------------------------
-- Indexes structure for table Category
-- ----------------------------
CREATE INDEX "IX_Category_CategoryParentId" ON "public"."Category" USING btree (
  "CategoryParentId" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE UNIQUE INDEX "PK_Category" ON "public"."Category" USING btree (
  Id "pg_catalog"."int8_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table Category
-- ----------------------------
ALTER TABLE "public"."Category" ADD CONSTRAINT "pk_category" PRIMARY KEY ("Id");

-- ----------------------------
-- Foreign Keys structure for table Category
-- ----------------------------
ALTER TABLE "public"."Category" ADD CONSTRAINT "fk_category_category_categoryparentid" FOREIGN KEY ("CategoryParentId") REFERENCES "public"."Category" (Id) ON DELETE NO ACTION ON UPDATE NO ACTION;


-- ----------------------------
-- Table structure for Worker
-- ----------------------------
DROP TABLE IF EXISTS "public"."Worker";
CREATE TABLE "public"."Worker" (
  Id int8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (
INCREMENT 1
MINVALUE  1
MAXVALUE 9223372036854775807
START 1
),
  "Name" varchar(50) COLLATE "pg_catalog"."default" NOT NULL,
  "StartDate" timestamptz(6) NOT NULL,
  "FinishDate" timestamptz(6) NOT NULL,
  "PublishingDate" timestamptz(6) NOT NULL,
  "ShortDescription" varchar(250) COLLATE "pg_catalog"."default" NOT NULL,
  "LongDescription" varchar(500) COLLATE "pg_catalog"."default" NOT NULL,
  "Price" float8 NOT NULL DEFAULT 0.0,
  "OrderPriority" int4 NOT NULL DEFAULT 1,
  "NeedId" bool NOT NULL DEFAULT false,
  "NeedSnack" bool NOT NULL DEFAULT false,
  "Payment" varchar(20) COLLATE "pg_catalog"."default" NOT NULL,
  "CategoryId" int8 NOT NULL,
  "Created" timestamptz(6) NOT NULL,
  "LastModified" timestamptz(6),
  "StatusBaseEntity" int4 NOT NULL
)
;

-- ----------------------------
-- Indexes structure for table Worker
-- ----------------------------
CREATE INDEX "IX_Worker_CategoryId" ON "public"."Worker" USING btree (
  "CategoryId" "pg_catalog"."int8_ops" ASC NULLS LAST
);
CREATE UNIQUE INDEX "PK_Worker" ON "public"."Worker" USING btree (
  Id "pg_catalog"."int8_ops" ASC NULLS LAST
);

-- ----------------------------
-- Primary Key structure for table Worker
-- ----------------------------
ALTER TABLE "public"."Worker" ADD CONSTRAINT "pk_Worker" PRIMARY KEY (Id);

-- ----------------------------
-- Foreign Keys structure for table Worker
-- ----------------------------
ALTER TABLE "public"."Worker" ADD CONSTRAINT "fk_Worker_category_categoryid" FOREIGN KEY ("CategoryId") REFERENCES "public"."Category" (Id) ON DELETE CASCADE ON UPDATE NO ACTION;




 % ./mock-darwin-amd64-v3.0 d -f -u testme-a localhost -q
INFO[2023-10-31 10:43:31] Version of the database: PostgreSQL 12.14 on x86_64-apple-darwin21.6.0, compiled by Apple clang version 14.0.0 (clang-1400.0.29.202), 64-bit
INFO[2023-10-31 10:43:31] The flavour of postgres is: postgres
INFO[2023-10-31 10:43:31] The database that will be used by mock program is: postgres
INFO[2023-10-31 10:43:31] Starting the program to mock full database
INFO[2023-10-31 10:43:31] Extracting the tables in the database: postgres
INFO[2023-10-31 10:43:31] Beginning the mocking process for the tables
INFO[2023-10-31 10:43:31] Extracting the columns and data type information
Extracting column information from tables 100% [==================================================] (2/2)
INFO[2023-10-31 10:43:31] Saving all the backup files to the path: /Users/testme/mock/20231031104331
INFO[2023-10-31 10:43:31] Total numbers of tables to mock: 2
Mocking Table "public"."Worker" 100% [==================================================] (10/10)
Mocking Table "public"."Category" 100% [==================================================] (10/10)
INFO[2023-10-31 10:43:31] Completed loading mock data to 2 tables
INFO[2023-10-31 10:43:31] Found 1 violation of primary keys, if found any attempting to fix them
Fixing primary keys violation 100% [==================================================] (1/1)
INFO[2023-10-31 10:43:31] Found 4 violation of unique keys, if found any attempting to fix them
Fixing unique keys violation 100% [==================================================] (4/4)
INFO[2023-10-31 10:43:31] Found 0 violation of foreign keys, if found any attempting to fix them
INFO[2023-10-31 10:43:31] Attempting to recreating all the constraints
Recreating the constraint type "p" 100% [==================================================] (1/1)
Recreating the constraint type "u" 100% [==================================================] (4/4)
INFO[2023-10-31 10:43:32] Successfully completed running the database sub command
%

I will get that fixed. Thanks for reporting the bug

Thanks a loot for your answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants