Kaynağa Gözat

docs(core): Add warning on changing primary key type

Michael Bromley 3 yıl önce
ebeveyn
işleme
cb83f9ddf0

+ 7 - 0
packages/core/src/config/entity-id-strategy/entity-id-strategy.ts

@@ -12,6 +12,13 @@ export type PrimaryKeyType<T> = T extends 'uuid' ? string : T extends 'increment
  * but custom strategies can be used, e.g. to apply some custom encoding to the ID before exposing
  * it in the GraphQL API.
  *
+ * {{% alert "warning" %}}
+ * Note: changing from an integer-based strategy to a uuid-based strategy
+ * on an existing Vendure database will lead to problems with broken foreign-key
+ * references. To change primary key types like this, you'll need to start with
+ * a fresh database.
+ * {{% /alert %}}
+ *
  * @docsCategory configuration
  * @docsPage EntityIdStrategy
  * */

+ 9 - 0
packages/core/src/config/vendure-config.ts

@@ -833,6 +833,8 @@ export interface JobQueueOptions {
  *
  * @since 1.3.0
  * @docsCategory configuration
+ * @docsPage EntityOptions
+ * @docsWeight 0
  */
 export interface EntityOptions {
     /**
@@ -842,6 +844,13 @@ export interface EntityOptions {
      * entities via the API. The default uses a simple auto-increment integer
      * strategy.
      *
+     * {{% alert "warning" %}}
+     * Note: changing from an integer-based strategy to a uuid-based strategy
+     * on an existing Vendure database will lead to problems with broken foreign-key
+     * references. To change primary key types like this, you'll need to start with
+     * a fresh database.
+     * {{% /alert %}}
+     *
      * @since 1.3.0
      * @default AutoIncrementIdStrategy
      */