import { t } from "@tailor-platform/sdk";
import { defineSchema } from "@tailor-platform/sdk/seed";
import { createTailorDBHook, createStandardSchema } from "@tailor-platform/sdk/test";
import { productVariant } from "../../src/modules-db";

const schemaType = t.object({
  ...productVariant.pickFields(["id","createdAt"], { optional: true }),
  ...productVariant.omitFields(["id","createdAt"]),
});

const hook = createTailorDBHook(productVariant);

export const schema = defineSchema(
  createStandardSchema(schemaType, hook),
  {
    foreignKeys: [
      {"column":"productId","references":{"table":"Product","column":"id"}},
      {"column":"itemId","references":{"table":"Item","column":"id"}},
    ],
    indexes: [
      {"name":"product_variant_unique_idx","columns":["productId","axisValueKey"],"unique":true},
    ],
  }
);
