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

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

const hook = createTailorDBHook(unit);

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