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

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

const hook = createTailorDBHook(productAttributeValue);

export const schema = defineSchema(
  createStandardSchema(schemaType, hook),
  {
    foreignKeys: [
      {"column":"attributeId","references":{"table":"ProductAttribute","column":"id"}},
    ],
    indexes: [
      {"name":"product_attribute_value_unique_idx","columns":["attributeId","label"],"unique":true},
    ],
  }
);
