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

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

const hook = createTailorDBHook(taxonomyNode);

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