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

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

const hook = createTailorDBHook(productCategoryAssignment);

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