Open sanyamsinghal opened 1 year ago
I had initially created a new GH issue for this, not knowing one already existed - https://github.com/yugabyte/yb-voyager/issues/1285
There have been additional users who have run into issues with the way we export schema into two different DDLs (CREATE TABLE
& ALTER TABLE...ADD CONSTRAINT...PRIMARY KEY
) . I have added the examples in the issue I created above but will re-iterate here:
x_restore_multi_region=# ALTER TABLE ONLY public.account_values ADD CONSTRAINT account_values_pkey PRIMARY KEY (id); ERROR: insufficient columns in PRIMARY KEY constraint definition DETAIL: PRIMARY KEY constraint on table "account_values" lacks column "geo_location" which is part of the partition key. x_restore_multi_region=# ALTER TABLE ONLY public.account_values ADD CONSTRAINT account_values_pkey PRIMARY KEY (id,geo_location); ERROR: changing primary key of a partitioned table is not yet implemented HINT: See https://github.com/yugabyte/yugabyte-db/issues/16980. React with thumbs up to raise its priority
We can avoid both of these by creating the PRIMARY KEY
as part of the CREATE TABLE
syntax as shown in our examples.
Jira Link: DB-13486 If we have a Partitioned Table in which
PRIMARY KEY
is added later on usingALTER TABLE
then it fails with the following error:Workaround: Add
PRIMARY KEY
in theCREATE TABLE
statement and remove correspondingALTER TABLE
statement.Sample Exported Schema:
Suggested Changes: