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

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

const hook = createTailorDBHook(product);

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