You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to share my experience using the migration tool. My database environment is PostgreSQL 14, and I had two problems.
First, when we run migrations, the script throws an error regarding FK violations related countryID into "Address" entity, because it is referring Region ID, but we need to add "Country" data into "Region" before creating this PK. Simply put, the value of FOREIGN KEY(address) provided in the ALTER statement is not present in the source (region) table.
So, to solve this problem we add the FK creation after step 3 like this.
// Run the data migrations functionawaitvendureV2Migrations(queryRunner);awaitqueryRunner.query(`ALTER TABLE "address" ADD CONSTRAINT "FK_d87215343c3a3a67e6a0b7f3ea9" FOREIGN KEY ("countryId") REFERENCES "region"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,undefined);
Second, in vendureV2Migrations function when set the currencyCode on all ProductVariantePrice entities based on the associated Channel, thows PSQLException: ERROR: operator does not exist: uuid = character varying
awaitq(`UPDATE "product_variant_price" SET "currencyCode" = (SELECT "defaultCurrencyCode" FROM "channel" WHERE "id" = "channelId")`);
Instead of putting the string "channelId" in the "WHERE" condition, I put the default channel code condition, but maybe this is not the traversal solution.
I hope this helps.
Best.
Carlo
The text was updated successfully, but these errors were encountered:
I want to share my experience using the migration tool. My database environment is PostgreSQL 14, and I had two problems.
First, when we run migrations, the script throws an error regarding FK violations related countryID into "Address" entity, because it is referring Region ID, but we need to add "Country" data into "Region" before creating this PK. Simply put, the value of FOREIGN KEY(address) provided in the ALTER statement is not present in the source (region) table.
So, to solve this problem we add the FK creation after step 3 like this.
Second, in vendureV2Migrations function when set the currencyCode on all ProductVariantePrice entities based on the associated Channel, thows PSQLException: ERROR: operator does not exist: uuid = character varying
Instead of putting the string "channelId" in the "WHERE" condition, I put the default channel code condition, but maybe this is not the traversal solution.
I hope this helps.
Best.
Carlo
The text was updated successfully, but these errors were encountered: