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

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

const hook = createTailorDBHook(itemTaxonomyAssignment);

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