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

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

const hook = createTailorDBHook(productCategory);

export const schema = defineSchema(
  createStandardSchema(schemaType, hook),
  {
    foreignKeys: [
      {"column":"parentId","references":{"table":"ProductCategory","column":"id"}},
    ],
    indexes: [
      {"name":"productcategory_code_unique_idx","columns":["code"],"unique":true},
    ],
  }
);
