-
+
+
+
+
+
+ {form.formState.isSubmitting && (
+
+ )}
+ Bijwerken
+
+
+
+
-
+
{mapIsLoaded ? (
)}
-
-
-
@@ -494,6 +527,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
undefined,
undefined,
undefined,
+ formValues.b_bufferstrip,
)
const cultivations = await getCultivations(
diff --git a/fdm-app/app/routes/farm.create.$b_id_farm.$calendar.fields.tsx b/fdm-app/app/routes/farm.create.$b_id_farm.$calendar.fields.tsx
index fac40b4ed..7348eed1c 100644
--- a/fdm-app/app/routes/farm.create.$b_id_farm.$calendar.fields.tsx
+++ b/fdm-app/app/routes/farm.create.$b_id_farm.$calendar.fields.tsx
@@ -107,7 +107,7 @@ export default function Index() {
() =>
fields
.filter((field) =>
- showProductiveOnly ? field.b_isproductive : true,
+ showProductiveOnly ? field.b_bufferstrip === false : true,
)
.slice()
.sort((a, b) => b.b_area - a.b_area) // Sort by area in descending order
diff --git a/fdm-calculator/src/balance/nitrogen/index.test.ts b/fdm-calculator/src/balance/nitrogen/index.test.ts
index 21d627a96..b0aed1329 100644
--- a/fdm-calculator/src/balance/nitrogen/index.test.ts
+++ b/fdm-calculator/src/balance/nitrogen/index.test.ts
@@ -1,18 +1,24 @@
-import { describe, expect, it, vi } from "vitest"
-import { calculateNitrogenBalance } from "."
-import type { NitrogenBalanceInput } from "./types"
+import { describe, expect, it } from "vitest"
+import {
+ calculateNitrogenBalance,
+ calculateNitrogenBalancesFieldToFarm,
+} from "."
+import type {
+ NitrogenBalanceInput,
+ NitrogenBalanceFieldResultNumeric,
+} from "./types"
import type { FdmType } from "@svenvw/fdm-core"
import Decimal from "decimal.js"
// Mock FdmType
const mockFdm = {
- select: vi.fn().mockReturnThis(),
- from: vi.fn().mockReturnThis(),
- where: vi.fn().mockReturnThis(),
- limit: vi.fn().mockReturnThis(),
- then: vi.fn((resolve) => resolve ? Promise.resolve(resolve([])) : Promise.resolve([])), // Simulate cache miss
- insert: vi.fn().mockReturnThis(),
- values: vi.fn().mockResolvedValue(undefined),
+ select: () => mockFdm,
+ from: () => mockFdm,
+ where: () => mockFdm,
+ limit: () => mockFdm,
+ execute: async () => [], // Simulate cache miss
+ insert: () => mockFdm,
+ values: async () => undefined,
} as unknown as FdmType
describe("calculateNitrogenBalance", () => {
@@ -26,6 +32,7 @@ describe("calculateNitrogenBalance", () => {
b_area: 100,
b_start: new Date("2023-01-01"),
b_end: new Date("2023-12-31"),
+ b_bufferstrip: false,
},
cultivations: [
{
@@ -172,6 +179,7 @@ describe("calculateNitrogenBalance", () => {
b_area: 100,
b_start: new Date("2023-01-01"),
b_end: new Date("2023-12-31"),
+ b_bufferstrip: false,
},
cultivations: [],
harvests: [],
@@ -198,4 +206,127 @@ describe("calculateNitrogenBalance", () => {
expect(result.hasErrors).toBe(true)
expect(result.fieldErrorMessages.length).toBeGreaterThan(0)
})
+
+ it("should return zero balance for buffer strips", async () => {
+ const mockNitrogenBalanceInput: NitrogenBalanceInput = {
+ fields: [
+ {
+ field: {
+ b_id: "field1",
+ b_centroid: [5.0, 52.0],
+ b_area: 100,
+ b_start: new Date("2023-01-01"),
+ b_end: new Date("2023-12-31"),
+ b_bufferstrip: true,
+ },
+ cultivations: [],
+ harvests: [],
+ soilAnalyses: [],
+ fertilizerApplications: [],
+ depositionSupply: {
+ total: new Decimal(0),
+ },
+ },
+ ],
+ fertilizerDetails: [],
+ cultivationDetails: [],
+ timeFrame: {
+ start: new Date("2023-01-01"),
+ end: new Date("2023-12-31"),
+ },
+ }
+
+ const result = await calculateNitrogenBalance(
+ mockFdm,
+ mockNitrogenBalanceInput,
+ )
+
+ expect(result.hasErrors).toBe(false)
+ expect(result.fieldErrorMessages.length).toBe(0)
+ expect(result.balance).toBe(0)
+ expect(result.supply.total).toBe(0)
+ expect(result.removal.total).toBe(0)
+ expect(result.emission.total).toBe(0)
+ })
+
+ it("should ignore buffer strips in farm-level aggregation", () => {
+ const results: NitrogenBalanceFieldResultNumeric[] = [
+ {
+ b_id: "field1",
+ b_area: 10,
+ b_bufferstrip: false,
+ balance: {
+ balance: 100,
+ supply: {
+ total: 100,
+ deposition: { total: 0 },
+ fixation: { total: 0 },
+ mineralisation: { total: 0 },
+ fertilizers: {
+ total: 0,
+ mineral: { total: 0 },
+ manure: { total: 0 },
+ compost: { total: 0 },
+ other: { total: 0 },
+ },
+ } as any,
+ removal: {
+ total: 0,
+ harvests: { total: 0 },
+ residues: { total: 0 },
+ } as any,
+ target: 0,
+ emission: {
+ total: 0,
+ ammonia: {
+ total: 0,
+ fertilizers: {
+ total: 0,
+ mineral: { total: 0 },
+ manure: { total: 0 },
+ compost: { total: 0 },
+ other: { total: 0 },
+ },
+ residues: { total: 0 },
+ },
+ nitrate: { total: 0 },
+ } as any,
+ } as any,
+ },
+ {
+ b_id: "buffer1",
+ b_area: 100,
+ b_bufferstrip: true,
+ balance: {
+ balance: 0,
+ supply: {
+ total: 0,
+ deposition: { total: 0 },
+ fixation: { total: 0 },
+ mineralisation: { total: 0 },
+ fertilizers: {
+ total: 0,
+ mineral: { total: 0 },
+ manure: { total: 0 },
+ compost: { total: 0 },
+ other: { total: 0 },
+ },
+ } as any,
+ removal: { total: 0 } as any,
+ target: 0,
+ emission: { total: 0 } as any,
+ } as any,
+ },
+ ]
+
+ const farmBalance = calculateNitrogenBalancesFieldToFarm(
+ results,
+ false,
+ [],
+ )
+
+ // Should match field1 values exactly
+ expect(farmBalance.balance).toBe(100)
+ expect(farmBalance.supply.total).toBe(100)
+ })
})
diff --git a/fdm-calculator/src/balance/nitrogen/index.ts b/fdm-calculator/src/balance/nitrogen/index.ts
index 88d11acf8..c007f28b8 100644
--- a/fdm-calculator/src/balance/nitrogen/index.ts
+++ b/fdm-calculator/src/balance/nitrogen/index.ts
@@ -53,12 +53,14 @@ export async function calculateNitrogenBalance(
return {
b_id: fieldInput.field.b_id,
b_area: fieldInput.field.b_area ?? 0,
+ b_bufferstrip: fieldInput.field.b_bufferstrip ?? false,
balance,
}
} catch (error) {
return {
b_id: fieldInput.field.b_id,
b_area: fieldInput.field.b_area ?? 0,
+ b_bufferstrip: fieldInput.field.b_bufferstrip ?? false,
errorMessage:
error instanceof Error
? error.message
@@ -121,6 +123,48 @@ export function calculateNitrogenBalanceField(
throw new Error("Timeframe start and end dates must be provided.")
}
+ if (field.b_bufferstrip) {
+ return {
+ b_id: field.b_id,
+ balance: 0,
+ supply: {
+ total: 0,
+ fertilizers: {
+ total: 0,
+ mineral: { total: 0, applications: [] },
+ manure: { total: 0, applications: [] },
+ compost: { total: 0, applications: [] },
+ other: { total: 0, applications: [] },
+ },
+ fixation: { total: 0, cultivations: [] },
+ deposition: { total: 0 },
+ mineralisation: { total: 0 },
+ },
+ removal: {
+ total: 0,
+ harvests: { total: 0, harvests: [] },
+ residues: { total: 0, cultivations: [] },
+ },
+ emission: {
+ total: 0,
+ ammonia: {
+ total: 0,
+ fertilizers: {
+ total: 0,
+ mineral: { total: 0, applications: [] },
+ manure: { total: 0, applications: [] },
+ compost: { total: 0, applications: [] },
+ other: { total: 0, applications: [] },
+ },
+ residues: { total: 0, cultivations: [] },
+ grazing: undefined,
+ },
+ nitrate: { total: 0 },
+ },
+ target: 0,
+ }
+ }
+
const fertilizerDetailsMap = new Map(
fertilizerDetails.map((detail) => [detail.p_id_catalogue, detail]),
)
@@ -261,8 +305,9 @@ export function calculateNitrogenBalancesFieldToFarm(
fieldErrorMessages: string[],
): NitrogenBalanceNumeric {
// Filter out fields that have errors for aggregation
+ // Also filter out buffer strips as they should be ignored in the farm-level aggregation
const successfulFieldBalances = fieldsWithBalanceResults.filter(
- (result) => result.balance !== undefined,
+ (result) => result.balance !== undefined && !result.b_bufferstrip,
) as (NitrogenBalanceFieldResultNumeric & {
balance: NitrogenBalanceFieldNumeric
})[]
@@ -482,7 +527,8 @@ export function calculateNitrogenBalancesFieldToFarm(
fields: fieldsWithBalanceResults,
hasErrors:
hasErrors ||
- fieldsWithBalanceResults.length !== successfulFieldBalances.length,
+ fieldsWithBalanceResults.filter((result) => !result.b_bufferstrip)
+ .length !== successfulFieldBalances.length,
fieldErrorMessages: fieldErrorMessages,
}
diff --git a/fdm-calculator/src/balance/nitrogen/input.test.ts b/fdm-calculator/src/balance/nitrogen/input.test.ts
index 50877f65d..a70169571 100644
--- a/fdm-calculator/src/balance/nitrogen/input.test.ts
+++ b/fdm-calculator/src/balance/nitrogen/input.test.ts
@@ -92,7 +92,7 @@ describe("collectInputForNitrogenBalance", () => {
b_start: new Date("2023-01-01"),
b_end: new Date("2023-12-31"),
b_acquiring_method: "purchase",
- b_isproductive: true,
+ b_bufferstrip: false,
},
{
b_id: "field-2",
@@ -106,7 +106,7 @@ describe("collectInputForNitrogenBalance", () => {
b_start: new Date("2023-01-01"),
b_end: new Date("2023-12-31"),
b_acquiring_method: "purchase",
- b_isproductive: true,
+ b_bufferstrip: false,
},
]
const mockCultivationsData: Cultivation[] = [
@@ -287,11 +287,7 @@ describe("collectInputForNitrogenBalance", () => {
)
expect(
mockedCalculateAllFieldsNitrogenSupplyByDeposition,
- ).toHaveBeenCalledWith(
- expect.anything(),
- timeframe,
- expect.any(String),
- )
+ ).toHaveBeenCalledWith(expect.anything(), timeframe, expect.any(String))
})
it("should throw an error if getFields fails", async () => {
@@ -322,7 +318,7 @@ describe("collectInputForNitrogenBalance", () => {
b_start: new Date("2023-01-01"),
b_end: new Date("2023-12-31"),
b_acquiring_method: "purchase",
- b_isproductive: true,
+ b_bufferstrip: false,
},
]
mockedGetFields.mockResolvedValue(mockFieldsData)
diff --git a/fdm-calculator/src/balance/nitrogen/performance.test.ts b/fdm-calculator/src/balance/nitrogen/performance.test.ts
index 9dfdd00cb..43502cfd8 100644
--- a/fdm-calculator/src/balance/nitrogen/performance.test.ts
+++ b/fdm-calculator/src/balance/nitrogen/performance.test.ts
@@ -86,6 +86,7 @@ function generateMockData(numberOfFields: number): NitrogenBalanceInput {
b_area: Math.floor(Math.random() * 50 + 10), // Random area between 10 and 60
b_start: fieldStart,
b_end: fieldEnd,
+ b_bufferstrip: false,
}
const cultivations: FieldInput["cultivations"] = [
diff --git a/fdm-calculator/src/balance/nitrogen/supply/deposition.test.ts b/fdm-calculator/src/balance/nitrogen/supply/deposition.test.ts
index b627d8df0..96800a212 100644
--- a/fdm-calculator/src/balance/nitrogen/supply/deposition.test.ts
+++ b/fdm-calculator/src/balance/nitrogen/supply/deposition.test.ts
@@ -16,6 +16,7 @@ describe("calculateAllFieldsNitrogenSupplyByDeposition", () => {
b_id: "test_field_1",
b_start: new Date("2025-01-01"),
b_end: new Date("2025-12-31"),
+ b_bufferstrip: false,
},
cultivations: [],
harvests: [],
@@ -47,6 +48,7 @@ describe("calculateAllFieldsNitrogenSupplyByDeposition", () => {
b_id: "test_field_1",
b_start: new Date("2023-01-01"),
b_end: new Date("2023-12-31"),
+ b_bufferstrip: false,
},
cultivations: [],
harvests: [],
@@ -92,6 +94,7 @@ describe("calculateAllFieldsNitrogenSupplyByDeposition", () => {
b_id: "test_field_1",
b_start: new Date("2023-01-01"),
b_end: new Date("2023-12-31"),
+ b_bufferstrip: false,
},
cultivations: [],
harvests: [],
@@ -124,6 +127,7 @@ describe("calculateAllFieldsNitrogenSupplyByDeposition", () => {
b_id: "field_1",
b_start: new Date("2025-01-01"),
b_end: new Date("2025-12-31"),
+ b_bufferstrip: false,
},
cultivations: [],
harvests: [],
@@ -138,6 +142,7 @@ describe("calculateAllFieldsNitrogenSupplyByDeposition", () => {
b_id: "field_2",
b_start: new Date("2025-01-01"),
b_end: new Date("2025-12-31"),
+ b_bufferstrip: false,
},
cultivations: [],
harvests: [],
diff --git a/fdm-calculator/src/balance/nitrogen/types.d.ts b/fdm-calculator/src/balance/nitrogen/types.d.ts
index 5e661e32a..9ee81c845 100644
--- a/fdm-calculator/src/balance/nitrogen/types.d.ts
+++ b/fdm-calculator/src/balance/nitrogen/types.d.ts
@@ -469,7 +469,10 @@ export type SoilAnalysisPicked = Pick<
* Represents the structure of fields with related entities for nitrogen balance calculation
*/
export type FieldInput = {
- field: Pick
+ field: Pick<
+ Field,
+ "b_id" | "b_centroid" | "b_area" | "b_start" | "b_end" | "b_bufferstrip"
+ >
cultivations: Pick<
Cultivation,
| "b_lu"
@@ -670,6 +673,7 @@ export type NitrogenBalanceFieldNumeric = {
export type NitrogenBalanceFieldResultNumeric = {
b_id: string
b_area: number
+ b_bufferstrip: boolean
balance?: NitrogenBalanceFieldNumeric
errorMessage?: string
}
diff --git a/fdm-calculator/src/balance/organic-matter/index.test.ts b/fdm-calculator/src/balance/organic-matter/index.test.ts
index 4f0dbf336..dec455727 100644
--- a/fdm-calculator/src/balance/organic-matter/index.test.ts
+++ b/fdm-calculator/src/balance/organic-matter/index.test.ts
@@ -1,6 +1,5 @@
import Decimal from "decimal.js"
import { describe, expect, it, vi } from "vitest"
-import { convertOrganicMatterBalanceToNumeric } from "../shared/conversion"
import * as shared from "../shared/soil"
import * as degradation from "./degradation"
import {
@@ -27,6 +26,7 @@ describe("Organic Matter Balance Calculation", () => {
const mockField: FieldInput["field"] = {
b_id: "field1",
b_area: 10,
+ b_bufferstrip: false,
} as FieldInput["field"]
const mockCultivations: FieldInput["cultivations"] = []
const mockFertilizerApplications: FieldInput["fertilizerApplications"] = []
@@ -61,6 +61,24 @@ describe("Organic Matter Balance Calculation", () => {
expect(result.supply.total).toBe(500)
expect(result.degradation.total).toBe(-200)
})
+
+ it("should return zero balance for buffer strips", () => {
+ const result = calculateOrganicMatterBalanceField({
+ fieldInput: {
+ field: { ...mockField, b_bufferstrip: true },
+ cultivations: mockCultivations,
+ fertilizerApplications: mockFertilizerApplications,
+ soilAnalyses: mockSoilAnalyses,
+ },
+ fertilizerDetails: [],
+ cultivationDetails: [],
+ timeFrame,
+ })
+
+ expect(result.balance).toBe(0)
+ expect(result.supply.total).toBe(0)
+ expect(result.degradation.total).toBe(0)
+ })
})
describe("calculateOrganicMatterBalancesFieldToFarm", () => {
@@ -69,6 +87,7 @@ describe("Organic Matter Balance Calculation", () => {
{
b_id: "field1",
b_area: 10,
+ b_bufferstrip: false,
balance: {
supply: { total: 500 },
degradation: { total: -200 },
@@ -78,6 +97,7 @@ describe("Organic Matter Balance Calculation", () => {
{
b_id: "field2",
b_area: 5,
+ b_bufferstrip: false,
balance: {
supply: { total: 400 },
degradation: { total: -300 },
@@ -105,13 +125,14 @@ describe("Organic Matter Balance Calculation", () => {
{
b_id: "field1",
b_area: 10,
+ b_bufferstrip: false,
balance: {
balance: 300,
supply: { total: 500 },
degradation: { total: -200 },
} as OrganicMatterBalanceFieldNumeric,
},
- { b_id: "field2", b_area: 5, errorMessage: "Failed" },
+ { b_id: "field2", b_area: 5, errorMessage: "Failed", b_bufferstrip: false },
]
const farmBalance = calculateOrganicMatterBalancesFieldToFarm(
results,
@@ -125,37 +146,41 @@ describe("Organic Matter Balance Calculation", () => {
expect(farmBalance.degradation).toBeCloseTo(-200)
expect(farmBalance.balance).toBeCloseTo(300)
})
- })
- describe("convertOrganicMatterBalanceToNumeric", () => {
- it("should convert all Decimal types to numbers", () => {
- const farmBalanceDecimal = {
- balance: new Decimal(233.333),
- supply: new Decimal(466.666),
- degradation: new Decimal(-233.333),
- fields: [
- {
- b_id: "field1",
- b_area: 10,
- balance: {
- balance: new Decimal(300),
- supply: {},
- degradation: {},
- },
- },
- ],
- hasErrors: false,
- fieldErrorMessages: [],
- } as any
+ it("should ignore buffer strips in farm-level aggregation", () => {
+ const results: OrganicMatterBalanceFieldResultNumeric[] = [
+ {
+ b_id: "field1",
+ b_area: 10,
+ b_bufferstrip: false,
+ balance: {
+ supply: { total: 500 },
+ degradation: { total: -200 },
+ balance: 300,
+ } as OrganicMatterBalanceFieldNumeric,
+ },
+ {
+ b_id: "buffer1",
+ b_area: 100,
+ b_bufferstrip: true,
+ balance: {
+ supply: { total: 0 },
+ degradation: { total: 0 },
+ balance: 0,
+ } as OrganicMatterBalanceFieldNumeric,
+ },
+ ]
- const numericResult =
- convertOrganicMatterBalanceToNumeric(farmBalanceDecimal)
+ const farmBalance = calculateOrganicMatterBalancesFieldToFarm(
+ results,
+ false,
+ [],
+ )
- expect(typeof numericResult.balance).toBe("number")
- expect(typeof numericResult.supply).toBe("number")
- expect(typeof numericResult.degradation).toBe("number")
- expect(typeof numericResult.fields[0].balance).toBe("object")
- expect(numericResult.balance).toBe(233) // .round()
+ // Should match field1 values exactly
+ expect(farmBalance.supply).toBe(500)
+ expect(farmBalance.degradation).toBe(-200)
+ expect(farmBalance.balance).toBe(300)
})
})
})
diff --git a/fdm-calculator/src/balance/organic-matter/index.ts b/fdm-calculator/src/balance/organic-matter/index.ts
index 3061cddc6..465905913 100644
--- a/fdm-calculator/src/balance/organic-matter/index.ts
+++ b/fdm-calculator/src/balance/organic-matter/index.ts
@@ -59,12 +59,14 @@ export async function calculateOrganicMatterBalance(
return {
b_id: fieldInput.field.b_id,
b_area: fieldInput.field.b_area ?? 0,
+ b_bufferstrip: fieldInput.field.b_bufferstrip ?? false,
balance,
}
} catch (error) {
return {
b_id: fieldInput.field.b_id,
b_area: fieldInput.field.b_area ?? 0,
+ b_bufferstrip: fieldInput.field.b_bufferstrip ?? false,
errorMessage:
error instanceof Error
? error.message
@@ -111,6 +113,25 @@ export function calculateOrganicMatterBalanceField(
const { field, cultivations, fertilizerApplications, soilAnalyses } =
fieldInput
+ if (field.b_bufferstrip) {
+ return {
+ b_id: field.b_id,
+ balance: 0,
+ supply: {
+ total: 0,
+ fertilizers: {
+ total: 0,
+ manure: { total: 0, applications: [] },
+ compost: { total: 0, applications: [] },
+ other: { total: 0, applications: [] },
+ },
+ cultivations: { total: 0, cultivations: [] },
+ residues: { total: 0, cultivations: [] },
+ },
+ degradation: { total: 0 },
+ } as OrganicMatterBalanceFieldNumeric
+ }
+
const fertilizerDetailsMap = new Map(
fertilizerDetails.map((detail: FertilizerDetail) => [
detail.p_id_catalogue,
@@ -194,8 +215,9 @@ export function calculateOrganicMatterBalancesFieldToFarm(
fieldErrorMessages: string[],
): OrganicMatterBalanceNumeric {
// Filter out fields that have errors to ensure they are not included in the aggregation.
+ // Also filter out buffer strips as they should be ignored in the farm-level aggregation
const successfulFieldBalances = fieldsWithBalanceResults.filter(
- (result) => result.balance !== undefined,
+ (result) => result.balance !== undefined && !result.b_bufferstrip,
) as (OrganicMatterBalanceFieldResultNumeric & {
balance: OrganicMatterBalanceFieldNumeric
})[]
@@ -234,7 +256,10 @@ export function calculateOrganicMatterBalancesFieldToFarm(
supply: avgFarmSupply,
degradation: avgFarmDegradation,
fields: fieldsWithBalanceResults,
- hasErrors,
+ hasErrors:
+ hasErrors ||
+ fieldsWithBalanceResults.filter((result) => !result.b_bufferstrip)
+ .length !== successfulFieldBalances.length,
fieldErrorMessages,
}) as OrganicMatterBalanceNumeric
}
diff --git a/fdm-calculator/src/balance/organic-matter/performance.test.ts b/fdm-calculator/src/balance/organic-matter/performance.test.ts
index 3c9ef7e40..d92a8ceab 100644
--- a/fdm-calculator/src/balance/organic-matter/performance.test.ts
+++ b/fdm-calculator/src/balance/organic-matter/performance.test.ts
@@ -73,6 +73,7 @@ function generateMockData(numberOfFields: number): OrganicMatterBalanceInput {
b_area: Math.floor(Math.random() * 50 + 10), // Random area between 10 and 60
b_start: fieldStart,
b_end: fieldEnd,
+ b_bufferstrip: false,
}
const cultivations: FieldInput["cultivations"] = [
diff --git a/fdm-calculator/src/balance/organic-matter/types.ts b/fdm-calculator/src/balance/organic-matter/types.ts
index a7c9c309f..648fad0a8 100644
--- a/fdm-calculator/src/balance/organic-matter/types.ts
+++ b/fdm-calculator/src/balance/organic-matter/types.ts
@@ -153,6 +153,8 @@ export type OrganicMatterBalanceFieldResult = {
b_id: string
/** The area of the field in hectares. */
b_area: number
+ /** Whether the field is a buffer strip */
+ b_bufferstrip: boolean
/** The detailed organic matter balance for the field. Undefined if an error occurred. */
balance?: OrganicMatterBalanceField
/** An error message if the calculation for this field failed. */
@@ -193,7 +195,10 @@ export type SoilAnalysisPicked = Pick<
*/
export type FieldInput = {
/** The core details of the field. */
- field: Pick
+ field: Pick<
+ Field,
+ "b_id" | "b_centroid" | "b_area" | "b_start" | "b_end" | "b_bufferstrip"
+ >
/** The list of cultivations that took place on the field. */
cultivations: Pick<
Cultivation,
@@ -328,9 +333,15 @@ export type OrganicMatterBalanceFieldNumeric = {
/** Numeric version of `OrganicMatterBalanceFieldResult`. */
export type OrganicMatterBalanceFieldResultNumeric = {
+ /** The unique identifier of the field. */
b_id: string
+ /** The area of the field in hectares. */
b_area: number
+ /** Whether the field is a buffer strip */
+ b_bufferstrip: boolean
+ /** The detailed organic matter balance for the field. Undefined if an error occurred. */
balance?: OrganicMatterBalanceFieldNumeric
+ /** An error message if the calculation for this field failed. */
errorMessage?: string
}
diff --git a/fdm-calculator/src/balance/shared/conversion.ts b/fdm-calculator/src/balance/shared/conversion.ts
index 9de35276a..2ae864f77 100644
--- a/fdm-calculator/src/balance/shared/conversion.ts
+++ b/fdm-calculator/src/balance/shared/conversion.ts
@@ -1,9 +1,4 @@
import Decimal from "decimal.js"
-import type {
- OrganicMatterBalance,
- OrganicMatterBalanceFieldNumeric,
- OrganicMatterBalanceNumeric,
-} from "../organic-matter/types"
// Helper function to convert Decimal to number recursively
export function convertDecimalToNumberRecursive(data: unknown): unknown {
@@ -33,31 +28,3 @@ export function convertDecimalToNumberRecursive(data: unknown): unknown {
}
return data
}
-
-// Main conversion function for OrganicMatterBalance
-export function convertOrganicMatterBalanceToNumeric(
- balance: OrganicMatterBalance,
-): OrganicMatterBalanceNumeric {
- const numericBalance = convertDecimalToNumberRecursive(
- balance,
- ) as OrganicMatterBalanceNumeric
-
- numericBalance.fields = balance.fields.map((fieldResult) => {
- if (fieldResult.balance) {
- return {
- b_id: fieldResult.b_id,
- b_area: fieldResult.b_area,
- balance: convertDecimalToNumberRecursive(
- fieldResult.balance,
- ) as OrganicMatterBalanceFieldNumeric,
- }
- }
- return {
- b_id: fieldResult.b_id,
- b_area: fieldResult.b_area,
- errorMessage: fieldResult.errorMessage,
- }
- })
-
- return numericBalance
-}
diff --git a/fdm-calculator/src/norms/nl/2025/value/dierlijke-mest-gebruiksnorm.test.ts b/fdm-calculator/src/norms/nl/2025/value/dierlijke-mest-gebruiksnorm.test.ts
index 5cc52cb10..cbcb814d2 100644
--- a/fdm-calculator/src/norms/nl/2025/value/dierlijke-mest-gebruiksnorm.test.ts
+++ b/fdm-calculator/src/norms/nl/2025/value/dierlijke-mest-gebruiksnorm.test.ts
@@ -12,6 +12,7 @@ describe("calculateNL2025DierlijkeMestGebruiksNorm", () => {
field: {
b_id: "1",
b_centroid: [5.641351453912945, 51.97755938887036],
+ b_bufferstrip: false,
},
cultivations: [],
soilAnalysis: { a_p_cc: 0, a_p_al: 0 },
@@ -27,6 +28,7 @@ describe("calculateNL2025DierlijkeMestGebruiksNorm", () => {
field: {
b_id: "1",
b_centroid: [5.641351453912945, 51.97755938887036],
+ b_bufferstrip: false,
},
cultivations: [],
soilAnalysis: { a_p_cc: 0, a_p_al: 0 },
@@ -42,6 +44,7 @@ describe("calculateNL2025DierlijkeMestGebruiksNorm", () => {
field: {
b_id: "1",
b_centroid: [5.654759168118452, 51.987887874110555],
+ b_bufferstrip: false,
},
cultivations: [],
soilAnalysis: { a_p_cc: 0, a_p_al: 0 },
@@ -57,6 +60,7 @@ describe("calculateNL2025DierlijkeMestGebruiksNorm", () => {
field: {
b_id: "1",
b_centroid: [5.654759168118452, 51.987887874110555],
+ b_bufferstrip: false,
},
cultivations: [],
soilAnalysis: { a_p_cc: 0, a_p_al: 0 },
@@ -72,6 +76,7 @@ describe("calculateNL2025DierlijkeMestGebruiksNorm", () => {
field: {
b_id: "1",
b_centroid: [6.397701151566514, 52.56657210653102],
+ b_bufferstrip: false,
},
cultivations: [],
soilAnalysis: { a_p_cc: 0, a_p_al: 0 },
@@ -89,6 +94,7 @@ describe("calculateNL2025DierlijkeMestGebruiksNorm", () => {
field: {
b_id: "1",
b_centroid: [5.058131582583726, 52.50733333508596],
+ b_bufferstrip: false,
},
cultivations: [],
soilAnalysis: { a_p_cc: 0, a_p_al: 0 },
@@ -104,6 +110,7 @@ describe("calculateNL2025DierlijkeMestGebruiksNorm", () => {
field: {
b_id: "1",
b_centroid: [5.804910408558418, 52.04532099948795], // Coordinates within a Natura 2000 area (Veluwe)
+ b_bufferstrip: false,
},
cultivations: [],
soilAnalysis: { a_p_cc: 0, a_p_al: 0 },
@@ -113,6 +120,22 @@ describe("calculateNL2025DierlijkeMestGebruiksNorm", () => {
expect(result.normSource).toBe("Derogatie - Natura2000 Gebied")
})
+ it("should return 0 for buffer strips", async () => {
+ const mockInput: NL2025NormsInput = {
+ farm: { is_derogatie_bedrijf: true, has_grazing_intention: false },
+ field: {
+ b_id: "1",
+ b_centroid: [5.641351453912945, 51.97755938887036],
+ b_bufferstrip: true,
+ },
+ cultivations: [],
+ soilAnalysis: { a_p_cc: 0, a_p_al: 0 },
+ }
+ const result = await calculateNL2025DierlijkeMestGebruiksNorm(mockInput)
+ expect(result.normValue).toBe(0)
+ expect(result.normSource).toBe("Bufferstrook: geen plaatsingsruimte")
+ })
+
describe("isFieldInDerogatieVrijeZone", () => {
it("should return true for a location inside the derogatie-vrije zone", async () => {
const locationInside: [number, number] = [
diff --git a/fdm-calculator/src/norms/nl/2025/value/dierlijke-mest-gebruiksnorm.ts b/fdm-calculator/src/norms/nl/2025/value/dierlijke-mest-gebruiksnorm.ts
index e4b953717..f8625f980 100644
--- a/fdm-calculator/src/norms/nl/2025/value/dierlijke-mest-gebruiksnorm.ts
+++ b/fdm-calculator/src/norms/nl/2025/value/dierlijke-mest-gebruiksnorm.ts
@@ -151,6 +151,14 @@ export async function calculateNL2025DierlijkeMestGebruiksNorm(
const is_derogatie_bedrijf = input.farm.is_derogatie_bedrijf || false
const field = input.field
+ // Check for buffer strip
+ if (field.b_bufferstrip) {
+ return {
+ normValue: 0,
+ normSource: "Bufferstrook: geen plaatsingsruimte",
+ }
+ }
+
const [
is_nv_gebied,
is_gwbg_gebied,
diff --git a/fdm-calculator/src/norms/nl/2025/value/fosfaatgebruiksnorm.test.ts b/fdm-calculator/src/norms/nl/2025/value/fosfaatgebruiksnorm.test.ts
index 08df4dae4..949f874a7 100644
--- a/fdm-calculator/src/norms/nl/2025/value/fosfaatgebruiksnorm.test.ts
+++ b/fdm-calculator/src/norms/nl/2025/value/fosfaatgebruiksnorm.test.ts
@@ -9,6 +9,7 @@ describe("calculateNL2025FosfaatGebruiksNorm", () => {
field: {
b_id: "1",
b_centroid: [5.0, 52.0],
+ b_bufferstrip: false,
},
cultivations: [
{
@@ -28,6 +29,7 @@ describe("calculateNL2025FosfaatGebruiksNorm", () => {
field: {
b_id: "1",
b_centroid: [5.0, 52.0],
+ b_bufferstrip: false,
},
cultivations: [
{
@@ -40,4 +42,24 @@ describe("calculateNL2025FosfaatGebruiksNorm", () => {
expect(result.normValue).toBe(120)
expect(result.normSource).toContain("Bouwland")
})
+
+ it("should return 0 for buffer strips", async () => {
+ const mockInput: NL2025NormsInput = {
+ farm: { is_derogatie_bedrijf: false, has_grazing_intention: true },
+ field: {
+ b_id: "1",
+ b_centroid: [5.0, 52.0],
+ b_bufferstrip: true,
+ },
+ cultivations: [
+ {
+ b_lu_catalogue: "nl_101",
+ } as Partial,
+ ] as NL2025NormsInputForCultivation[],
+ soilAnalysis: { a_p_al: 20, a_p_cc: 0.9 },
+ }
+ const result = await calculateNL2025FosfaatGebruiksNorm(mockInput)
+ expect(result.normValue).toBe(0)
+ expect(result.normSource).toBe("Bufferstrook: geen plaatsingsruimte")
+ })
})
diff --git a/fdm-calculator/src/norms/nl/2025/value/fosfaatgebruiksnorm.ts b/fdm-calculator/src/norms/nl/2025/value/fosfaatgebruiksnorm.ts
index ff2078c35..f02400be7 100644
--- a/fdm-calculator/src/norms/nl/2025/value/fosfaatgebruiksnorm.ts
+++ b/fdm-calculator/src/norms/nl/2025/value/fosfaatgebruiksnorm.ts
@@ -133,6 +133,15 @@ function getFosfaatKlasse(
export async function calculateNL2025FosfaatGebruiksNorm(
input: NL2025NormsInput,
): Promise {
+ const field = input.field
+ // Check for buffer strip
+ if (field.b_bufferstrip) {
+ return {
+ normValue: 0,
+ normSource: "Bufferstrook: geen plaatsingsruimte",
+ }
+ }
+
const cultivations = input.cultivations
const a_p_cc = input.soilAnalysis.a_p_cc
const a_p_al = input.soilAnalysis.a_p_al
diff --git a/fdm-calculator/src/norms/nl/2025/value/stikstofgebruiksnorm.test.ts b/fdm-calculator/src/norms/nl/2025/value/stikstofgebruiksnorm.test.ts
index f9332cb23..fa530dbcf 100644
--- a/fdm-calculator/src/norms/nl/2025/value/stikstofgebruiksnorm.test.ts
+++ b/fdm-calculator/src/norms/nl/2025/value/stikstofgebruiksnorm.test.ts
@@ -9,7 +9,8 @@ import {
import type { NL2025NormsInput, NL2025NormsInputForCultivation } from "./types"
vi.mock("../../../../shared/geotiff", async (importActual) => {
- const actual = await importActual()
+ const actual =
+ await importActual()
return {
...actual,
getGeoTiffValue: vi.fn(actual.getGeoTiffValue),
@@ -90,6 +91,29 @@ describe(" calculateNL2025StikstofGebruiksNorm", () => {
expect(result.normSource).toEqual("Grasland (volledig maaien).")
})
+ it("should return 0 for buffer strips", async () => {
+ const mockInput: NL2025NormsInput = {
+ farm: { is_derogatie_bedrijf: false, has_grazing_intention: false },
+ field: {
+ b_id: "1",
+ b_centroid: [5.6279889, 51.975571],
+ b_bufferstrip: true,
+ } as Field,
+ cultivations: [
+ {
+ b_lu_catalogue: "nl_265",
+ b_lu_start: new Date(2025, 0, 1),
+ b_lu_end: new Date(2025, 5, 1),
+ } as Partial,
+ ] as NL2025NormsInputForCultivation[],
+ soilAnalysis: { a_p_al: 20, a_p_cc: 0.9 },
+ }
+
+ const result = await calculateNL2025StikstofGebruiksNorm(mockInput)
+ expect(result.normValue).toBe(0)
+ expect(result.normSource).toEqual("Bufferstrook: geen plaatsingsruimte")
+ })
+
it("should return the correct norm for potatoes", async () => {
const mockInput: NL2025NormsInput = {
farm: { is_derogatie_bedrijf: false, has_grazing_intention: false },
diff --git a/fdm-calculator/src/norms/nl/2025/value/stikstofgebruiksnorm.ts b/fdm-calculator/src/norms/nl/2025/value/stikstofgebruiksnorm.ts
index ee12f7ce1..ff1bbcfdd 100644
--- a/fdm-calculator/src/norms/nl/2025/value/stikstofgebruiksnorm.ts
+++ b/fdm-calculator/src/norms/nl/2025/value/stikstofgebruiksnorm.ts
@@ -814,6 +814,14 @@ export async function calculateNL2025StikstofGebruiksNorm(
const field = input.field
const cultivations = input.cultivations
+ // Check for buffer strip
+ if (field.b_bufferstrip) {
+ return {
+ normValue: 0,
+ normSource: "Bufferstrook: geen plaatsingsruimte",
+ }
+ }
+
// Determine hoofdteelt
const b_lu_catalogue = determineNLHoofdteelt(cultivations, 2025)
let cultivation = cultivations.find(
diff --git a/fdm-calculator/src/norms/nl/2025/value/types.d.ts b/fdm-calculator/src/norms/nl/2025/value/types.d.ts
index 8a99739d4..1d4ee0d78 100644
--- a/fdm-calculator/src/norms/nl/2025/value/types.d.ts
+++ b/fdm-calculator/src/norms/nl/2025/value/types.d.ts
@@ -18,7 +18,7 @@ export type NL2025NormsInput = {
has_grazing_intention: boolean
}
/** The field record from fdm-core, including its ID and centroid for location-based checks. */
- field: Pick
+ field: Pick
/** An array of all cultivations on the field with their required norm inputs. */
cultivations: NL2025NormsInputForCultivation[]
/** The most recent soil analysis data available before the start of the cultivation. */
diff --git a/fdm-calculator/src/norms/nl/2026/value/dierlijke-mest-gebruiksnorm.test.ts b/fdm-calculator/src/norms/nl/2026/value/dierlijke-mest-gebruiksnorm.test.ts
index d84d497cf..9912b3e0e 100644
--- a/fdm-calculator/src/norms/nl/2026/value/dierlijke-mest-gebruiksnorm.test.ts
+++ b/fdm-calculator/src/norms/nl/2026/value/dierlijke-mest-gebruiksnorm.test.ts
@@ -1,10 +1,32 @@
import { describe, expect, it } from "vitest"
import { calculateNL2026DierlijkeMestGebruiksNorm } from "./dierlijke-mest-gebruiksnorm"
+import type { NL2026NormsInput } from "./types"
describe("calculateNL2026DierlijkeMestGebruiksNorm", () => {
it("should return the default norm value", async () => {
- const result = await calculateNL2026DierlijkeMestGebruiksNorm()
+ const input: NL2026NormsInput = {
+ farm: { has_grazing_intention: false },
+ field: {
+ b_id: "field-1",
+ b_centroid: [0, 0],
+ b_bufferstrip: false,
+ },
+ cultivations: [],
+ soilAnalysis: { a_p_al: 0, a_p_cc: 0 },
+ }
+ const result = await calculateNL2026DierlijkeMestGebruiksNorm(input)
expect(result.normValue).toBe(170)
expect(result.normSource).toBe("Standaard - geen derogatie")
})
+
+ it("should return 0 for buffer strips", async () => {
+ const input = {
+ field: {
+ b_bufferstrip: true,
+ },
+ } as NL2026NormsInput
+ const result = await calculateNL2026DierlijkeMestGebruiksNorm(input)
+ expect(result.normValue).toBe(0)
+ expect(result.normSource).toBe("Bufferstrook: geen plaatsingsruimte")
+ })
})
diff --git a/fdm-calculator/src/norms/nl/2026/value/dierlijke-mest-gebruiksnorm.ts b/fdm-calculator/src/norms/nl/2026/value/dierlijke-mest-gebruiksnorm.ts
index bcacb023f..a4208f438 100644
--- a/fdm-calculator/src/norms/nl/2026/value/dierlijke-mest-gebruiksnorm.ts
+++ b/fdm-calculator/src/norms/nl/2026/value/dierlijke-mest-gebruiksnorm.ts
@@ -2,12 +2,15 @@ import { withCalculationCache } from "@svenvw/fdm-core"
import pkg from "../../../../package"
import type { DierlijkeMestGebruiksnormResult } from "../../types"
+import type { NL2026NormsInput } from "./types"
+
/**
* Determines the 'gebruiksnorm' (usage standard) for nitrogen from animal manure
* for a given farm and parcel in the Netherlands for the year 2026.
*
* This function implements the rules and norms specified by the RVO for 2026.
*
+ * @param input - An object of type `NL2026NormsInput` containing all necessary data.
* @returns An object of type `DierlijkeMestGebruiksnormResult` containing the determined
* nitrogen usage standard (`normValue`) and a `normSource` string explaining the rule applied.
*
@@ -16,7 +19,19 @@ import type { DierlijkeMestGebruiksnormResult } from "../../types"
* - **Standard Norm**: The norm is 170 kg N/ha from animal manure.
* - **No Derogation**: Derogation rules do not apply for 2026.
*/
-export async function calculateNL2026DierlijkeMestGebruiksNorm(): Promise {
+export async function calculateNL2026DierlijkeMestGebruiksNorm(
+ input: NL2026NormsInput,
+): Promise {
+ const field = input.field
+
+ // Check for buffer strip
+ if (field.b_bufferstrip) {
+ return {
+ normValue: 0,
+ normSource: "Bufferstrook: geen plaatsingsruimte",
+ }
+ }
+
const normValue = 170
const normSource = "Standaard - geen derogatie"
diff --git a/fdm-calculator/src/norms/nl/2026/value/fosfaatgebruiksnorm.test.ts b/fdm-calculator/src/norms/nl/2026/value/fosfaatgebruiksnorm.test.ts
index 44c5fe200..423be361f 100644
--- a/fdm-calculator/src/norms/nl/2026/value/fosfaatgebruiksnorm.test.ts
+++ b/fdm-calculator/src/norms/nl/2026/value/fosfaatgebruiksnorm.test.ts
@@ -9,6 +9,7 @@ describe("calculateNL2026FosfaatGebruiksNorm", () => {
field: {
b_id: "1",
b_centroid: [5.0, 52.0],
+ b_bufferstrip: false,
},
cultivations: [
{
@@ -28,6 +29,7 @@ describe("calculateNL2026FosfaatGebruiksNorm", () => {
field: {
b_id: "1",
b_centroid: [5.0, 52.0],
+ b_bufferstrip: false,
},
cultivations: [
{
@@ -40,4 +42,24 @@ describe("calculateNL2026FosfaatGebruiksNorm", () => {
expect(result.normValue).toBe(120)
expect(result.normSource).toContain("Bouwland")
})
+
+ it("should return 0 for buffer strips", async () => {
+ const mockInput: NL2026NormsInput = {
+ farm: { has_grazing_intention: true },
+ field: {
+ b_id: "1",
+ b_centroid: [5.0, 52.0],
+ b_bufferstrip: true,
+ },
+ cultivations: [
+ {
+ b_lu_catalogue: "nl_101",
+ } as Partial,
+ ] as NL2026NormsInputForCultivation[],
+ soilAnalysis: { a_p_al: 20, a_p_cc: 0.9 },
+ }
+ const result = await calculateNL2026FosfaatGebruiksNorm(mockInput)
+ expect(result.normValue).toBe(0)
+ expect(result.normSource).toBe("Bufferstrook: geen plaatsingsruimte")
+ })
})
diff --git a/fdm-calculator/src/norms/nl/2026/value/fosfaatgebruiksnorm.ts b/fdm-calculator/src/norms/nl/2026/value/fosfaatgebruiksnorm.ts
index 4fdbf5776..6fb600403 100644
--- a/fdm-calculator/src/norms/nl/2026/value/fosfaatgebruiksnorm.ts
+++ b/fdm-calculator/src/norms/nl/2026/value/fosfaatgebruiksnorm.ts
@@ -123,6 +123,15 @@ function getFosfaatKlasse(
export async function calculateNL2026FosfaatGebruiksNorm(
input: NL2026NormsInput,
): Promise {
+ const field = input.field
+ // Check for buffer strip
+ if (field.b_bufferstrip) {
+ return {
+ normValue: 0,
+ normSource: "Bufferstrook: geen plaatsingsruimte",
+ }
+ }
+
const cultivations = input.cultivations
const a_p_cc = input.soilAnalysis.a_p_cc
const a_p_al = input.soilAnalysis.a_p_al
diff --git a/fdm-calculator/src/norms/nl/2026/value/stikstofgebruiksnorm.test.ts b/fdm-calculator/src/norms/nl/2026/value/stikstofgebruiksnorm.test.ts
index a659a5e37..ad159f7ee 100644
--- a/fdm-calculator/src/norms/nl/2026/value/stikstofgebruiksnorm.test.ts
+++ b/fdm-calculator/src/norms/nl/2026/value/stikstofgebruiksnorm.test.ts
@@ -48,6 +48,29 @@ describe("calculateNL2026StikstofGebruiksNorm", () => {
expect(result.normSource).toEqual("Grasland (volledig maaien).")
})
+ it("should return 0 for buffer strips", async () => {
+ const mockInput: NL2026NormsInput = {
+ farm: { has_grazing_intention: false },
+ field: {
+ b_id: "1",
+ b_centroid: [5.6279889, 51.975571],
+ b_bufferstrip: true,
+ } as Field,
+ cultivations: [
+ {
+ b_lu_catalogue: "nl_265",
+ b_lu_start: new Date(2026, 0, 1),
+ b_lu_end: new Date(2026, 5, 1),
+ } as Partial,
+ ] as NL2026NormsInputForCultivation[],
+ soilAnalysis: { a_p_al: 20, a_p_cc: 0.9 },
+ }
+
+ const result = await calculateNL2026StikstofGebruiksNorm(mockInput)
+ expect(result.normValue).toBe(0)
+ expect(result.normSource).toEqual("Bufferstrook: geen plaatsingsruimte")
+ })
+
it("should return the correct norm for potatoes", async () => {
const mockInput: NL2026NormsInput = {
farm: { has_grazing_intention: false },
diff --git a/fdm-calculator/src/norms/nl/2026/value/stikstofgebruiksnorm.ts b/fdm-calculator/src/norms/nl/2026/value/stikstofgebruiksnorm.ts
index 27e420cf3..dd3b76f33 100644
--- a/fdm-calculator/src/norms/nl/2026/value/stikstofgebruiksnorm.ts
+++ b/fdm-calculator/src/norms/nl/2026/value/stikstofgebruiksnorm.ts
@@ -650,6 +650,14 @@ export async function calculateNL2026StikstofGebruiksNorm(
const field = input.field
const cultivations = input.cultivations
+ // Check for buffer strip
+ if (field.b_bufferstrip) {
+ return {
+ normValue: 0,
+ normSource: "Bufferstrook: geen plaatsingsruimte",
+ }
+ }
+
// Determine hoofdteelt
const b_lu_catalogue = determineNLHoofdteelt(cultivations, 2026)
let cultivation = cultivations.find(
diff --git a/fdm-calculator/src/norms/nl/2026/value/types.d.ts b/fdm-calculator/src/norms/nl/2026/value/types.d.ts
index 290972cf9..3de218920 100644
--- a/fdm-calculator/src/norms/nl/2026/value/types.d.ts
+++ b/fdm-calculator/src/norms/nl/2026/value/types.d.ts
@@ -17,7 +17,7 @@ export type NL2026NormsInput = {
has_grazing_intention: boolean
}
/** The field record from fdm-core, including its ID and centroid for location-based checks. */
- field: Pick
+ field: Pick
/** An array of all cultivations on the field with their required norm inputs. */
cultivations: NL2026NormsInputForCultivation[]
/** The most recent soil analysis data available before the start of the cultivation. */
diff --git a/fdm-calculator/src/nutrient-advice/index.test.ts b/fdm-calculator/src/nutrient-advice/index.test.ts
index 91750fe33..4e4925a6c 100644
--- a/fdm-calculator/src/nutrient-advice/index.test.ts
+++ b/fdm-calculator/src/nutrient-advice/index.test.ts
@@ -155,4 +155,21 @@ describe("requestNutrientAdvice", () => {
)
expect(fetch).toHaveBeenCalledTimes(1)
})
+
+ it("should return zero advice for buffer strips without calling NMI API", async () => {
+ const inputs: NutrientAdviceInputs = {
+ b_lu_catalogue: "nl_2014",
+ b_centroid: [4.3, 52.4],
+ currentSoilData: mockCurrentSoilData,
+ nmiApiKey: "mock-api-key",
+ b_bufferstrip: true,
+ }
+
+ const result = await requestNutrientAdvice(inputs)
+
+ expect(fetch).not.toHaveBeenCalled()
+ expect(result.d_n_req).toBe(0)
+ expect(result.d_p_req).toBe(0)
+ expect(result.d_k_req).toBe(0)
+ })
})
diff --git a/fdm-calculator/src/nutrient-advice/index.ts b/fdm-calculator/src/nutrient-advice/index.ts
index 5e46c5815..b44f9f373 100644
--- a/fdm-calculator/src/nutrient-advice/index.ts
+++ b/fdm-calculator/src/nutrient-advice/index.ts
@@ -21,8 +21,31 @@ export async function requestNutrientAdvice({
b_centroid,
currentSoilData,
nmiApiKey,
+ b_bufferstrip,
}: NutrientAdviceInputs): Promise {
try {
+ if (b_bufferstrip) {
+ return {
+ d_n_req: 0,
+ d_n_norm: 0,
+ d_n_norm_man: 0,
+ d_p_norm: 0,
+ d_p_req: 0,
+ d_k_req: 0,
+ d_c_req: 0,
+ d_ca_req: 0,
+ d_s_req: 0,
+ d_mg_req: 0,
+ d_cu_req: 0,
+ d_zn_req: 0,
+ d_co_req: 0,
+ d_mn_req: 0,
+ d_mo_req: 0,
+ d_na_req: 0,
+ d_b_req: 0,
+ }
+ }
+
if (!nmiApiKey) {
throw new Error("NMI API key not provided")
}
diff --git a/fdm-calculator/src/nutrient-advice/types.d.ts b/fdm-calculator/src/nutrient-advice/types.d.ts
index b73d7e9d8..cc426728f 100644
--- a/fdm-calculator/src/nutrient-advice/types.d.ts
+++ b/fdm-calculator/src/nutrient-advice/types.d.ts
@@ -84,4 +84,6 @@ export type NutrientAdviceInputs = {
currentSoilData: CurrentSoilData
/** NMI API key for authentication */
nmiApiKey: string | undefined
+ /** Indicates if the field is a buffer strip */
+ b_bufferstrip?: boolean
}
diff --git a/fdm-core/src/cultivation.d.ts b/fdm-core/src/cultivation.d.ts
index 7409b04e5..39f38bc3d 100644
--- a/fdm-core/src/cultivation.d.ts
+++ b/fdm-core/src/cultivation.d.ts
@@ -38,7 +38,7 @@ export interface CultivationPlan {
b_id: schema.fieldsTypeSelect["b_id"]
b_area: number
b_name: schema.fieldsTypeSelect["b_name"]
- b_isproductive: boolean
+ b_bufferstrip: schema.fieldsTypeSelect["b_bufferstrip"]
fertilizer_applications: Array<{
p_id_catalogue: schema.fertilizersCatalogueTypeSelect["p_id_catalogue"]
p_name_nl: schema.fertilizersCatalogueTypeSelect["p_name_nl"]
diff --git a/fdm-core/src/cultivation.ts b/fdm-core/src/cultivation.ts
index 023913d79..8be5642d0 100644
--- a/fdm-core/src/cultivation.ts
+++ b/fdm-core/src/cultivation.ts
@@ -23,7 +23,6 @@ import type {
import * as schema from "./db/schema"
import { handleError } from "./error"
import type { FdmType } from "./fdm"
-import { determineIfFieldIsProductive } from "./field"
import {
addHarvest,
getDefaultsForHarvestParameters,
@@ -706,7 +705,7 @@ export async function getCultivations(
* b_id: string; // Unique ID of the field
* b_name: string; // Name of the field
* b_area: number; // Area of the field
- * b_isproductive: boolean; // Whether the field is productive
+ * b_bufferstrip: boolean; // Whether the field is a bufferstrip
* fertilizer_applications: [
* {
* p_id_catalogue: string; // Fertilizer catalogue ID
@@ -786,6 +785,7 @@ export async function getCultivationPlan(
b_name: schema.fields.b_name,
b_area: sql`ROUND((ST_Area(b_geometry::geography)/10000)::NUMERIC, 2)::FLOAT`,
b_perimeter: sql`ROUND((ST_Length(ST_ExteriorRing(b_geometry)::geography))::NUMERIC, 2)::FLOAT`,
+ b_bufferstrip: schema.fields.b_bufferstrip,
b_lu_start: schema.cultivationStarting.b_lu_start,
b_lu_end: schema.cultivationEnding.b_lu_end,
m_cropresidue: schema.cultivationEnding.m_cropresidue,
@@ -957,11 +957,7 @@ export async function getCultivationPlan(
b_id: curr.b_id,
b_area: curr.b_area,
b_name: curr.b_name,
- b_isproductive: determineIfFieldIsProductive(
- curr.b_area,
- curr.b_perimeter,
- curr.b_name,
- ),
+ b_bufferstrip: curr.b_bufferstrip,
fertilizer_applications: [],
harvests: [],
}
diff --git a/fdm-core/src/db/migrations/0021_exotic_mesmero.sql b/fdm-core/src/db/migrations/0021_exotic_mesmero.sql
new file mode 100644
index 000000000..b580de7fb
--- /dev/null
+++ b/fdm-core/src/db/migrations/0021_exotic_mesmero.sql
@@ -0,0 +1 @@
+ALTER TABLE "fdm"."fields" ADD COLUMN "b_bufferstrip" boolean DEFAULT false NOT NULL;
\ No newline at end of file
diff --git a/fdm-core/src/db/migrations/0022_calculate_bufferstrips.sql b/fdm-core/src/db/migrations/0022_calculate_bufferstrips.sql
new file mode 100644
index 000000000..048f15188
--- /dev/null
+++ b/fdm-core/src/db/migrations/0022_calculate_bufferstrips.sql
@@ -0,0 +1,9 @@
+UPDATE "fdm"."fields"
+SET "b_bufferstrip" = COALESCE(
+ (
+ ST_Length(ST_ExteriorRing(b_geometry)::geography) / NULLIF(SQRT(ST_Area(b_geometry::geography)), 0) >= 20
+ AND ST_Area(b_geometry::geography) < 25000
+ ),
+ FALSE
+)
+OR b_name ILIKE '%buffer%';
diff --git a/fdm-core/src/db/migrations/meta/0021_snapshot.json b/fdm-core/src/db/migrations/meta/0021_snapshot.json
new file mode 100644
index 000000000..aac2827eb
--- /dev/null
+++ b/fdm-core/src/db/migrations/meta/0021_snapshot.json
@@ -0,0 +1,3623 @@
+{
+ "id": "68820e10-7b74-4632-9d86-500508549bb8",
+ "prevId": "1eb64507-01b4-41c6-8583-c114db99b60f",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "fdm.cultivation_catalogue_selecting": {
+ "name": "cultivation_catalogue_selecting",
+ "schema": "fdm",
+ "columns": {
+ "b_id_farm": {
+ "name": "b_id_farm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_lu_source": {
+ "name": "b_lu_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "cultivation_catalogue_selecting_b_id_farm_farms_b_id_farm_fk": {
+ "name": "cultivation_catalogue_selecting_b_id_farm_farms_b_id_farm_fk",
+ "tableFrom": "cultivation_catalogue_selecting",
+ "tableTo": "farms",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id_farm"],
+ "columnsTo": ["b_id_farm"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.cultivation_ending": {
+ "name": "cultivation_ending",
+ "schema": "fdm",
+ "columns": {
+ "b_lu": {
+ "name": "b_lu",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_lu_end": {
+ "name": "b_lu_end",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "m_cropresidue": {
+ "name": "m_cropresidue",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "cultivation_ending_b_lu_cultivations_b_lu_fk": {
+ "name": "cultivation_ending_b_lu_cultivations_b_lu_fk",
+ "tableFrom": "cultivation_ending",
+ "tableTo": "cultivations",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_lu"],
+ "columnsTo": ["b_lu"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.cultivation_harvesting": {
+ "name": "cultivation_harvesting",
+ "schema": "fdm",
+ "columns": {
+ "b_id_harvesting": {
+ "name": "b_id_harvesting",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "b_id_harvestable": {
+ "name": "b_id_harvestable",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_lu": {
+ "name": "b_lu",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_lu_harvest_date": {
+ "name": "b_lu_harvest_date",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "cultivation_harvesting_b_id_harvestable_harvestables_b_id_harvestable_fk": {
+ "name": "cultivation_harvesting_b_id_harvestable_harvestables_b_id_harvestable_fk",
+ "tableFrom": "cultivation_harvesting",
+ "tableTo": "harvestables",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id_harvestable"],
+ "columnsTo": ["b_id_harvestable"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "cultivation_harvesting_b_lu_cultivations_b_lu_fk": {
+ "name": "cultivation_harvesting_b_lu_cultivations_b_lu_fk",
+ "tableFrom": "cultivation_harvesting",
+ "tableTo": "cultivations",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_lu"],
+ "columnsTo": ["b_lu"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.cultivation_starting": {
+ "name": "cultivation_starting",
+ "schema": "fdm",
+ "columns": {
+ "b_id": {
+ "name": "b_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_lu": {
+ "name": "b_lu",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_lu_start": {
+ "name": "b_lu_start",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_sowing_amount": {
+ "name": "b_sowing_amount",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_sowing_method": {
+ "name": "b_sowing_method",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "cultivation_starting_b_id_fields_b_id_fk": {
+ "name": "cultivation_starting_b_id_fields_b_id_fk",
+ "tableFrom": "cultivation_starting",
+ "tableTo": "fields",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id"],
+ "columnsTo": ["b_id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "cultivation_starting_b_lu_cultivations_b_lu_fk": {
+ "name": "cultivation_starting_b_lu_cultivations_b_lu_fk",
+ "tableFrom": "cultivation_starting",
+ "tableTo": "cultivations",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_lu"],
+ "columnsTo": ["b_lu"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.cultivations": {
+ "name": "cultivations",
+ "schema": "fdm",
+ "columns": {
+ "b_lu": {
+ "name": "b_lu",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "b_lu_catalogue": {
+ "name": "b_lu_catalogue",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_lu_variety": {
+ "name": "b_lu_variety",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "b_lu_idx": {
+ "name": "b_lu_idx",
+ "columns": [
+ {
+ "expression": "b_lu",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cultivations_b_lu_catalogue_cultivations_catalogue_b_lu_catalogue_fk": {
+ "name": "cultivations_b_lu_catalogue_cultivations_catalogue_b_lu_catalogue_fk",
+ "tableFrom": "cultivations",
+ "tableTo": "cultivations_catalogue",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_lu_catalogue"],
+ "columnsTo": ["b_lu_catalogue"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.cultivations_catalogue": {
+ "name": "cultivations_catalogue",
+ "schema": "fdm",
+ "columns": {
+ "b_lu_catalogue": {
+ "name": "b_lu_catalogue",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "b_lu_source": {
+ "name": "b_lu_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_lu_name": {
+ "name": "b_lu_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_lu_name_en": {
+ "name": "b_lu_name_en",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_harvestable": {
+ "name": "b_lu_harvestable",
+ "type": "b_lu_harvestable",
+ "typeSchema": "fdm",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_lu_harvestcat": {
+ "name": "b_lu_harvestcat",
+ "type": "b_lu_harvestcat",
+ "typeSchema": "fdm",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_hcat3": {
+ "name": "b_lu_hcat3",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_hcat3_name": {
+ "name": "b_lu_hcat3_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_croprotation": {
+ "name": "b_lu_croprotation",
+ "type": "b_lu_croprotation",
+ "typeSchema": "fdm",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_yield": {
+ "name": "b_lu_yield",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_dm": {
+ "name": "b_lu_dm",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_hi": {
+ "name": "b_lu_hi",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_n_harvestable": {
+ "name": "b_lu_n_harvestable",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_n_residue": {
+ "name": "b_lu_n_residue",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_n_fixation": {
+ "name": "b_n_fixation",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_eom": {
+ "name": "b_lu_eom",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_eom_residues": {
+ "name": "b_lu_eom_residues",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_rest_oravib": {
+ "name": "b_lu_rest_oravib",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_variety_options": {
+ "name": "b_lu_variety_options",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_start_default": {
+ "name": "b_lu_start_default",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_date_harvest_default": {
+ "name": "b_date_harvest_default",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hash": {
+ "name": "hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "b_lu_catalogue_idx": {
+ "name": "b_lu_catalogue_idx",
+ "columns": [
+ {
+ "expression": "b_lu_catalogue",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "b_lu_start_default_format": {
+ "name": "b_lu_start_default_format",
+ "value": "b_lu_start_default IS NULL OR b_lu_start_default ~ '^(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$'"
+ },
+ "b_date_harvest_default_format": {
+ "name": "b_date_harvest_default_format",
+ "value": "b_date_harvest_default IS NULL OR b_date_harvest_default ~ '^(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$'"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "fdm.derogation_applying": {
+ "name": "derogation_applying",
+ "schema": "fdm",
+ "columns": {
+ "b_id_farm": {
+ "name": "b_id_farm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_id_derogation": {
+ "name": "b_id_derogation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "derogation_one_per_farm_per": {
+ "name": "derogation_one_per_farm_per",
+ "columns": [
+ {
+ "expression": "b_id_derogation",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "derogation_applying_b_id_farm_farms_b_id_farm_fk": {
+ "name": "derogation_applying_b_id_farm_farms_b_id_farm_fk",
+ "tableFrom": "derogation_applying",
+ "tableTo": "farms",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id_farm"],
+ "columnsTo": ["b_id_farm"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "derogation_applying_b_id_derogation_derogations_b_id_derogation_fk": {
+ "name": "derogation_applying_b_id_derogation_derogations_b_id_derogation_fk",
+ "tableFrom": "derogation_applying",
+ "tableTo": "derogations",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id_derogation"],
+ "columnsTo": ["b_id_derogation"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.derogations": {
+ "name": "derogations",
+ "schema": "fdm",
+ "columns": {
+ "b_id_derogation": {
+ "name": "b_id_derogation",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "b_derogation_year": {
+ "name": "b_derogation_year",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.farms": {
+ "name": "farms",
+ "schema": "fdm",
+ "columns": {
+ "b_id_farm": {
+ "name": "b_id_farm",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "b_name_farm": {
+ "name": "b_name_farm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_businessid_farm": {
+ "name": "b_businessid_farm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_address_farm": {
+ "name": "b_address_farm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_postalcode_farm": {
+ "name": "b_postalcode_farm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "b_id_farm_idx": {
+ "name": "b_id_farm_idx",
+ "columns": [
+ {
+ "expression": "b_id_farm",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.fertilizer_acquiring": {
+ "name": "fertilizer_acquiring",
+ "schema": "fdm",
+ "columns": {
+ "b_id_farm": {
+ "name": "b_id_farm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "p_id": {
+ "name": "p_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "p_acquiring_amount": {
+ "name": "p_acquiring_amount",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_acquiring_date": {
+ "name": "p_acquiring_date",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "fertilizer_acquiring_b_id_farm_farms_b_id_farm_fk": {
+ "name": "fertilizer_acquiring_b_id_farm_farms_b_id_farm_fk",
+ "tableFrom": "fertilizer_acquiring",
+ "tableTo": "farms",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id_farm"],
+ "columnsTo": ["b_id_farm"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "fertilizer_acquiring_p_id_fertilizers_p_id_fk": {
+ "name": "fertilizer_acquiring_p_id_fertilizers_p_id_fk",
+ "tableFrom": "fertilizer_acquiring",
+ "tableTo": "fertilizers",
+ "schemaTo": "fdm",
+ "columnsFrom": ["p_id"],
+ "columnsTo": ["p_id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.fertilizer_applying": {
+ "name": "fertilizer_applying",
+ "schema": "fdm",
+ "columns": {
+ "p_app_id": {
+ "name": "p_app_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "b_id": {
+ "name": "b_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "p_id": {
+ "name": "p_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "p_app_amount": {
+ "name": "p_app_amount",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_app_method": {
+ "name": "p_app_method",
+ "type": "p_app_method",
+ "typeSchema": "fdm",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_app_date": {
+ "name": "p_app_date",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "p_app_idx": {
+ "name": "p_app_idx",
+ "columns": [
+ {
+ "expression": "p_app_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "fertilizer_applying_b_id_fields_b_id_fk": {
+ "name": "fertilizer_applying_b_id_fields_b_id_fk",
+ "tableFrom": "fertilizer_applying",
+ "tableTo": "fields",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id"],
+ "columnsTo": ["b_id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "fertilizer_applying_p_id_fertilizers_p_id_fk": {
+ "name": "fertilizer_applying_p_id_fertilizers_p_id_fk",
+ "tableFrom": "fertilizer_applying",
+ "tableTo": "fertilizers",
+ "schemaTo": "fdm",
+ "columnsFrom": ["p_id"],
+ "columnsTo": ["p_id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.fertilizer_catalogue_enabling": {
+ "name": "fertilizer_catalogue_enabling",
+ "schema": "fdm",
+ "columns": {
+ "b_id_farm": {
+ "name": "b_id_farm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "p_source": {
+ "name": "p_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "fertilizer_catalogue_enabling_b_id_farm_farms_b_id_farm_fk": {
+ "name": "fertilizer_catalogue_enabling_b_id_farm_farms_b_id_farm_fk",
+ "tableFrom": "fertilizer_catalogue_enabling",
+ "tableTo": "farms",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id_farm"],
+ "columnsTo": ["b_id_farm"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.fertilizer_picking": {
+ "name": "fertilizer_picking",
+ "schema": "fdm",
+ "columns": {
+ "p_id": {
+ "name": "p_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "p_id_catalogue": {
+ "name": "p_id_catalogue",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "p_picking_date": {
+ "name": "p_picking_date",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "fertilizer_picking_p_id_fertilizers_p_id_fk": {
+ "name": "fertilizer_picking_p_id_fertilizers_p_id_fk",
+ "tableFrom": "fertilizer_picking",
+ "tableTo": "fertilizers",
+ "schemaTo": "fdm",
+ "columnsFrom": ["p_id"],
+ "columnsTo": ["p_id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "fertilizer_picking_p_id_catalogue_fertilizers_catalogue_p_id_catalogue_fk": {
+ "name": "fertilizer_picking_p_id_catalogue_fertilizers_catalogue_p_id_catalogue_fk",
+ "tableFrom": "fertilizer_picking",
+ "tableTo": "fertilizers_catalogue",
+ "schemaTo": "fdm",
+ "columnsFrom": ["p_id_catalogue"],
+ "columnsTo": ["p_id_catalogue"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.fertilizers": {
+ "name": "fertilizers",
+ "schema": "fdm",
+ "columns": {
+ "p_id": {
+ "name": "p_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "p_id_idx": {
+ "name": "p_id_idx",
+ "columns": [
+ {
+ "expression": "p_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.fertilizers_catalogue": {
+ "name": "fertilizers_catalogue",
+ "schema": "fdm",
+ "columns": {
+ "p_id_catalogue": {
+ "name": "p_id_catalogue",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "p_source": {
+ "name": "p_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "p_name_nl": {
+ "name": "p_name_nl",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "p_name_en": {
+ "name": "p_name_en",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_description": {
+ "name": "p_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_app_method_options": {
+ "name": "p_app_method_options",
+ "type": "p_app_method[]",
+ "typeSchema": "fdm",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_dm": {
+ "name": "p_dm",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_density": {
+ "name": "p_density",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_om": {
+ "name": "p_om",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_a": {
+ "name": "p_a",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_hc": {
+ "name": "p_hc",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_eom": {
+ "name": "p_eom",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_eoc": {
+ "name": "p_eoc",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_c_rt": {
+ "name": "p_c_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_c_of": {
+ "name": "p_c_of",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_c_if": {
+ "name": "p_c_if",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_c_fr": {
+ "name": "p_c_fr",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_cn_of": {
+ "name": "p_cn_of",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_n_rt": {
+ "name": "p_n_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_n_if": {
+ "name": "p_n_if",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_n_of": {
+ "name": "p_n_of",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_n_wc": {
+ "name": "p_n_wc",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_no3_rt": {
+ "name": "p_no3_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_nh4_rt": {
+ "name": "p_nh4_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_p_rt": {
+ "name": "p_p_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_k_rt": {
+ "name": "p_k_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_mg_rt": {
+ "name": "p_mg_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_ca_rt": {
+ "name": "p_ca_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_ne": {
+ "name": "p_ne",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_s_rt": {
+ "name": "p_s_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_s_wc": {
+ "name": "p_s_wc",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_cu_rt": {
+ "name": "p_cu_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_zn_rt": {
+ "name": "p_zn_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_na_rt": {
+ "name": "p_na_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_si_rt": {
+ "name": "p_si_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_b_rt": {
+ "name": "p_b_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_mn_rt": {
+ "name": "p_mn_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_ni_rt": {
+ "name": "p_ni_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_fe_rt": {
+ "name": "p_fe_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_mo_rt": {
+ "name": "p_mo_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_co_rt": {
+ "name": "p_co_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_as_rt": {
+ "name": "p_as_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_cd_rt": {
+ "name": "p_cd_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_cr_rt": {
+ "name": "p_cr_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_cr_vi": {
+ "name": "p_cr_vi",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_pb_rt": {
+ "name": "p_pb_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_hg_rt": {
+ "name": "p_hg_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_cl_rt": {
+ "name": "p_cl_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_ef_nh3": {
+ "name": "p_ef_nh3",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_type_manure": {
+ "name": "p_type_manure",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_type_mineral": {
+ "name": "p_type_mineral",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_type_compost": {
+ "name": "p_type_compost",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_type_rvo": {
+ "name": "p_type_rvo",
+ "type": "p_type_rvo",
+ "typeSchema": "fdm",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hash": {
+ "name": "hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "p_id_catalogue_idx": {
+ "name": "p_id_catalogue_idx",
+ "columns": [
+ {
+ "expression": "p_id_catalogue",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.field_acquiring": {
+ "name": "field_acquiring",
+ "schema": "fdm",
+ "columns": {
+ "b_id": {
+ "name": "b_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_id_farm": {
+ "name": "b_id_farm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_start": {
+ "name": "b_start",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_acquiring_method": {
+ "name": "b_acquiring_method",
+ "type": "b_acquiring_method",
+ "typeSchema": "fdm",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'unknown'"
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "field_acquiring_b_id_fields_b_id_fk": {
+ "name": "field_acquiring_b_id_fields_b_id_fk",
+ "tableFrom": "field_acquiring",
+ "tableTo": "fields",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id"],
+ "columnsTo": ["b_id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "field_acquiring_b_id_farm_farms_b_id_farm_fk": {
+ "name": "field_acquiring_b_id_farm_farms_b_id_farm_fk",
+ "tableFrom": "field_acquiring",
+ "tableTo": "farms",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id_farm"],
+ "columnsTo": ["b_id_farm"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.field_discarding": {
+ "name": "field_discarding",
+ "schema": "fdm",
+ "columns": {
+ "b_id": {
+ "name": "b_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_end": {
+ "name": "b_end",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "field_discarding_b_id_fields_b_id_fk": {
+ "name": "field_discarding_b_id_fields_b_id_fk",
+ "tableFrom": "field_discarding",
+ "tableTo": "fields",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id"],
+ "columnsTo": ["b_id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.fields": {
+ "name": "fields",
+ "schema": "fdm",
+ "columns": {
+ "b_id": {
+ "name": "b_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "b_name": {
+ "name": "b_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_geometry": {
+ "name": "b_geometry",
+ "type": "geometry(Polygon,4326)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_id_source": {
+ "name": "b_id_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_bufferstrip": {
+ "name": "b_bufferstrip",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "b_id_idx": {
+ "name": "b_id_idx",
+ "columns": [
+ {
+ "expression": "b_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "b_geom_idx": {
+ "name": "b_geom_idx",
+ "columns": [
+ {
+ "expression": "b_geometry",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "gist",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.harvestable_analyses": {
+ "name": "harvestable_analyses",
+ "schema": "fdm",
+ "columns": {
+ "b_id_harvestable_analysis": {
+ "name": "b_id_harvestable_analysis",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "b_lu_yield": {
+ "name": "b_lu_yield",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_yield_fresh": {
+ "name": "b_lu_yield_fresh",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_yield_bruto": {
+ "name": "b_lu_yield_bruto",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_tarra": {
+ "name": "b_lu_tarra",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_dm": {
+ "name": "b_lu_dm",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_moist": {
+ "name": "b_lu_moist",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_uww": {
+ "name": "b_lu_uww",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_cp": {
+ "name": "b_lu_cp",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_n_harvestable": {
+ "name": "b_lu_n_harvestable",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_n_residue": {
+ "name": "b_lu_n_residue",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_p_harvestable": {
+ "name": "b_lu_p_harvestable",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_p_residue": {
+ "name": "b_lu_p_residue",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_k_harvestable": {
+ "name": "b_lu_k_harvestable",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_k_residue": {
+ "name": "b_lu_k_residue",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "b_id_harvestable_analyses_idx": {
+ "name": "b_id_harvestable_analyses_idx",
+ "columns": [
+ {
+ "expression": "b_id_harvestable_analysis",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.harvestable_sampling": {
+ "name": "harvestable_sampling",
+ "schema": "fdm",
+ "columns": {
+ "b_id_harvestable": {
+ "name": "b_id_harvestable",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_id_harvestable_analysis": {
+ "name": "b_id_harvestable_analysis",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_sampling_date": {
+ "name": "b_sampling_date",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "harvestable_sampling_b_id_harvestable_harvestables_b_id_harvestable_fk": {
+ "name": "harvestable_sampling_b_id_harvestable_harvestables_b_id_harvestable_fk",
+ "tableFrom": "harvestable_sampling",
+ "tableTo": "harvestables",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id_harvestable"],
+ "columnsTo": ["b_id_harvestable"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "harvestable_sampling_b_id_harvestable_analysis_harvestable_analyses_b_id_harvestable_analysis_fk": {
+ "name": "harvestable_sampling_b_id_harvestable_analysis_harvestable_analyses_b_id_harvestable_analysis_fk",
+ "tableFrom": "harvestable_sampling",
+ "tableTo": "harvestable_analyses",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id_harvestable_analysis"],
+ "columnsTo": ["b_id_harvestable_analysis"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.harvestables": {
+ "name": "harvestables",
+ "schema": "fdm",
+ "columns": {
+ "b_id_harvestable": {
+ "name": "b_id_harvestable",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "b_id_harvestable_idx": {
+ "name": "b_id_harvestable_idx",
+ "columns": [
+ {
+ "expression": "b_id_harvestable",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.intending_grazing": {
+ "name": "intending_grazing",
+ "schema": "fdm",
+ "columns": {
+ "b_id_farm": {
+ "name": "b_id_farm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_grazing_intention": {
+ "name": "b_grazing_intention",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_grazing_intention_year": {
+ "name": "b_grazing_intention_year",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "intending_grazing_b_id_farm_farms_b_id_farm_fk": {
+ "name": "intending_grazing_b_id_farm_farms_b_id_farm_fk",
+ "tableFrom": "intending_grazing",
+ "tableTo": "farms",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id_farm"],
+ "columnsTo": ["b_id_farm"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "intending_grazing_b_id_farm_b_grazing_intention_year_pk": {
+ "name": "intending_grazing_b_id_farm_b_grazing_intention_year_pk",
+ "columns": ["b_id_farm", "b_grazing_intention_year"]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.organic_certifications": {
+ "name": "organic_certifications",
+ "schema": "fdm",
+ "columns": {
+ "b_id_organic": {
+ "name": "b_id_organic",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "b_organic_traces": {
+ "name": "b_organic_traces",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_organic_skal": {
+ "name": "b_organic_skal",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_organic_issued": {
+ "name": "b_organic_issued",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_organic_expires": {
+ "name": "b_organic_expires",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.organic_certifications_holding": {
+ "name": "organic_certifications_holding",
+ "schema": "fdm",
+ "columns": {
+ "b_id_farm": {
+ "name": "b_id_farm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_id_organic": {
+ "name": "b_id_organic",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "organic_one_farm_per_cert": {
+ "name": "organic_one_farm_per_cert",
+ "columns": [
+ {
+ "expression": "b_id_organic",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "organic_certifications_holding_b_id_farm_farms_b_id_farm_fk": {
+ "name": "organic_certifications_holding_b_id_farm_farms_b_id_farm_fk",
+ "tableFrom": "organic_certifications_holding",
+ "tableTo": "farms",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id_farm"],
+ "columnsTo": ["b_id_farm"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "organic_certifications_holding_b_id_organic_organic_certifications_b_id_organic_fk": {
+ "name": "organic_certifications_holding_b_id_organic_organic_certifications_b_id_organic_fk",
+ "tableFrom": "organic_certifications_holding",
+ "tableTo": "organic_certifications",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id_organic"],
+ "columnsTo": ["b_id_organic"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.soil_analysis": {
+ "name": "soil_analysis",
+ "schema": "fdm",
+ "columns": {
+ "a_id": {
+ "name": "a_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "a_date": {
+ "name": "a_date",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_source": {
+ "name": "a_source",
+ "type": "a_source",
+ "typeSchema": "fdm",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'other'"
+ },
+ "a_al_ox": {
+ "name": "a_al_ox",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_c_of": {
+ "name": "a_c_of",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_ca_co": {
+ "name": "a_ca_co",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_ca_co_po": {
+ "name": "a_ca_co_po",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_caco3_if": {
+ "name": "a_caco3_if",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_cec_co": {
+ "name": "a_cec_co",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_clay_mi": {
+ "name": "a_clay_mi",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_cn_fr": {
+ "name": "a_cn_fr",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_com_fr": {
+ "name": "a_com_fr",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_cu_cc": {
+ "name": "a_cu_cc",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_density_sa": {
+ "name": "a_density_sa",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_fe_ox": {
+ "name": "a_fe_ox",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_k_cc": {
+ "name": "a_k_cc",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_k_co": {
+ "name": "a_k_co",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_k_co_po": {
+ "name": "a_k_co_po",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_mg_cc": {
+ "name": "a_mg_cc",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_mg_co": {
+ "name": "a_mg_co",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_mg_co_po": {
+ "name": "a_mg_co_po",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_n_pmn": {
+ "name": "a_n_pmn",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_n_rt": {
+ "name": "a_n_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_nh4_cc": {
+ "name": "a_nh4_cc",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_nmin_cc": {
+ "name": "a_nmin_cc",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_no3_cc": {
+ "name": "a_no3_cc",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_p_al": {
+ "name": "a_p_al",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_p_cc": {
+ "name": "a_p_cc",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_p_ox": {
+ "name": "a_p_ox",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_p_rt": {
+ "name": "a_p_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_p_sg": {
+ "name": "a_p_sg",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_p_wa": {
+ "name": "a_p_wa",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_ph_cc": {
+ "name": "a_ph_cc",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_s_rt": {
+ "name": "a_s_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_sand_mi": {
+ "name": "a_sand_mi",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_silt_mi": {
+ "name": "a_silt_mi",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_som_loi": {
+ "name": "a_som_loi",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_zn_cc": {
+ "name": "a_zn_cc",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_gwl_class": {
+ "name": "b_gwl_class",
+ "type": "b_gwl_class",
+ "typeSchema": "fdm",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_soiltype_agr": {
+ "name": "b_soiltype_agr",
+ "type": "b_soiltype_agr",
+ "typeSchema": "fdm",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.soil_sampling": {
+ "name": "soil_sampling",
+ "schema": "fdm",
+ "columns": {
+ "b_id_sampling": {
+ "name": "b_id_sampling",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "b_id": {
+ "name": "b_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "a_id": {
+ "name": "a_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "a_depth_upper": {
+ "name": "a_depth_upper",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "a_depth_lower": {
+ "name": "a_depth_lower",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_sampling_date": {
+ "name": "b_sampling_date",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_sampling_geometry": {
+ "name": "b_sampling_geometry",
+ "type": "geometry(MultiPoint,4326)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "soil_sampling_b_id_fields_b_id_fk": {
+ "name": "soil_sampling_b_id_fields_b_id_fk",
+ "tableFrom": "soil_sampling",
+ "tableTo": "fields",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id"],
+ "columnsTo": ["b_id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "soil_sampling_a_id_soil_analysis_a_id_fk": {
+ "name": "soil_sampling_a_id_soil_analysis_a_id_fk",
+ "tableFrom": "soil_sampling",
+ "tableTo": "soil_analysis",
+ "schemaTo": "fdm",
+ "columnsFrom": ["a_id"],
+ "columnsTo": ["a_id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm-authn.account": {
+ "name": "account",
+ "schema": "fdm-authn",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password": {
+ "name": "password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "account_userId_idx": {
+ "name": "account_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "account_user_id_user_id_fk": {
+ "name": "account_user_id_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "schemaTo": "fdm-authn",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm-authn.invitation": {
+ "name": "invitation",
+ "schema": "fdm-authn",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "inviter_id": {
+ "name": "inviter_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "invitation_organizationId_idx": {
+ "name": "invitation_organizationId_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "invitation_email_idx": {
+ "name": "invitation_email_idx",
+ "columns": [
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "invitation_organization_id_organization_id_fk": {
+ "name": "invitation_organization_id_organization_id_fk",
+ "tableFrom": "invitation",
+ "tableTo": "organization",
+ "schemaTo": "fdm-authn",
+ "columnsFrom": ["organization_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "invitation_inviter_id_user_id_fk": {
+ "name": "invitation_inviter_id_user_id_fk",
+ "tableFrom": "invitation",
+ "tableTo": "user",
+ "schemaTo": "fdm-authn",
+ "columnsFrom": ["inviter_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm-authn.member": {
+ "name": "member",
+ "schema": "fdm-authn",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "member_organizationId_idx": {
+ "name": "member_organizationId_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "member_userId_idx": {
+ "name": "member_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "member_organization_id_organization_id_fk": {
+ "name": "member_organization_id_organization_id_fk",
+ "tableFrom": "member",
+ "tableTo": "organization",
+ "schemaTo": "fdm-authn",
+ "columnsFrom": ["organization_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "member_user_id_user_id_fk": {
+ "name": "member_user_id_user_id_fk",
+ "tableFrom": "member",
+ "tableTo": "user",
+ "schemaTo": "fdm-authn",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm-authn.organization": {
+ "name": "organization",
+ "schema": "fdm-authn",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "logo": {
+ "name": "logo",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "organization_slug_uidx": {
+ "name": "organization_slug_uidx",
+ "columns": [
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "organization_slug_unique": {
+ "name": "organization_slug_unique",
+ "nullsNotDistinct": false,
+ "columns": ["slug"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm-authn.rate_limit": {
+ "name": "rate_limit",
+ "schema": "fdm-authn",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "count": {
+ "name": "count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_request": {
+ "name": "last_request",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm-authn.session": {
+ "name": "session",
+ "schema": "fdm-authn",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "active_organization_id": {
+ "name": "active_organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "session_userId_idx": {
+ "name": "session_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "session_user_id_user_id_fk": {
+ "name": "session_user_id_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "schemaTo": "fdm-authn",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "session_token_unique": {
+ "name": "session_token_unique",
+ "nullsNotDistinct": false,
+ "columns": ["token"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm-authn.user": {
+ "name": "user",
+ "schema": "fdm-authn",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email_verified": {
+ "name": "email_verified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "username": {
+ "name": "username",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "display_username": {
+ "name": "display_username",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "firstname": {
+ "name": "firstname",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "surname": {
+ "name": "surname",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lang": {
+ "name": "lang",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'nl-NL'"
+ },
+ "farm_active": {
+ "name": "farm_active",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": ["email"]
+ },
+ "user_username_unique": {
+ "name": "user_username_unique",
+ "nullsNotDistinct": false,
+ "columns": ["username"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm-authn.verification": {
+ "name": "verification",
+ "schema": "fdm-authn",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "verification_identifier_idx": {
+ "name": "verification_identifier_idx",
+ "columns": [
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm-authz.audit": {
+ "name": "audit",
+ "schema": "fdm-authz",
+ "columns": {
+ "audit_id": {
+ "name": "audit_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "audit_timestamp": {
+ "name": "audit_timestamp",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "audit_origin": {
+ "name": "audit_origin",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "principal_id": {
+ "name": "principal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_resource": {
+ "name": "target_resource",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_resource_id": {
+ "name": "target_resource_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "granting_resource": {
+ "name": "granting_resource",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "granting_resource_id": {
+ "name": "granting_resource_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "allowed": {
+ "name": "allowed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "duration": {
+ "name": "duration",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm-authz.role": {
+ "name": "role",
+ "schema": "fdm-authz",
+ "columns": {
+ "role_id": {
+ "name": "role_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "resource": {
+ "name": "resource",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resource_id": {
+ "name": "resource_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "principal_id": {
+ "name": "principal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "deleted": {
+ "name": "deleted",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "role_idx": {
+ "name": "role_idx",
+ "columns": [
+ {
+ "expression": "resource",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "resource_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "principal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "role",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "deleted",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm-calculator.calculation_cache": {
+ "name": "calculation_cache",
+ "schema": "fdm-calculator",
+ "columns": {
+ "calculation_hash": {
+ "name": "calculation_hash",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "calculation_function": {
+ "name": "calculation_function",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "calculator_version": {
+ "name": "calculator_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "input": {
+ "name": "input",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result": {
+ "name": "result",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm-calculator.calculation_errors": {
+ "name": "calculation_errors",
+ "schema": "fdm-calculator",
+ "columns": {
+ "calculation_error_id": {
+ "name": "calculation_error_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "calculation_function": {
+ "name": "calculation_function",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "calculator_version": {
+ "name": "calculator_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "input": {
+ "name": "input",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stack_trace": {
+ "name": "stack_trace",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {
+ "fdm.b_acquiring_method": {
+ "name": "b_acquiring_method",
+ "schema": "fdm",
+ "values": [
+ "nl_01",
+ "nl_02",
+ "nl_03",
+ "nl_04",
+ "nl_07",
+ "nl_09",
+ "nl_10",
+ "nl_11",
+ "nl_12",
+ "nl_13",
+ "nl_61",
+ "nl_63",
+ "unknown"
+ ]
+ },
+ "fdm.p_app_method": {
+ "name": "p_app_method",
+ "schema": "fdm",
+ "values": [
+ "slotted coulter",
+ "incorporation",
+ "incorporation 2 tracks",
+ "injection",
+ "shallow injection",
+ "spraying",
+ "broadcasting",
+ "spoke wheel",
+ "pocket placement",
+ "narrowband"
+ ]
+ },
+ "fdm.b_gwl_class": {
+ "name": "b_gwl_class",
+ "schema": "fdm",
+ "values": [
+ "I",
+ "Ia",
+ "Ic",
+ "II",
+ "IIa",
+ "IIb",
+ "IIc",
+ "III",
+ "IIIa",
+ "IIIb",
+ "IV",
+ "IVu",
+ "IVc",
+ "V",
+ "Va",
+ "Vao",
+ "Vad",
+ "Vb",
+ "Vbo",
+ "Vbd",
+ "sV",
+ "sVb",
+ "VI",
+ "VIo",
+ "VId",
+ "VII",
+ "VIIo",
+ "VIId",
+ "VIII",
+ "VIIIo",
+ "VIIId"
+ ]
+ },
+ "fdm.b_lu_harvestcat": {
+ "name": "b_lu_harvestcat",
+ "schema": "fdm",
+ "values": [
+ "HC010",
+ "HC020",
+ "HC031",
+ "HC040",
+ "HC041",
+ "HC042",
+ "HC050"
+ ]
+ },
+ "fdm.b_lu_harvestable": {
+ "name": "b_lu_harvestable",
+ "schema": "fdm",
+ "values": ["none", "once", "multiple"]
+ },
+ "fdm.b_lu_croprotation": {
+ "name": "b_lu_croprotation",
+ "schema": "fdm",
+ "values": [
+ "other",
+ "clover",
+ "nature",
+ "potato",
+ "grass",
+ "rapeseed",
+ "starch",
+ "maize",
+ "cereal",
+ "sugarbeet",
+ "alfalfa",
+ "catchcrop"
+ ]
+ },
+ "fdm.a_source": {
+ "name": "a_source",
+ "schema": "fdm",
+ "values": [
+ "nl-rva-l122",
+ "nl-rva-l136",
+ "nl-rva-l264",
+ "nl-rva-l320",
+ "nl-rva-l335",
+ "nl-rva-l610",
+ "nl-rva-l648",
+ "nl-rva-l697",
+ "nl-other-nmi",
+ "other"
+ ]
+ },
+ "fdm.b_soiltype_agr": {
+ "name": "b_soiltype_agr",
+ "schema": "fdm",
+ "values": [
+ "moerige_klei",
+ "rivierklei",
+ "dekzand",
+ "zeeklei",
+ "dalgrond",
+ "veen",
+ "loess",
+ "duinzand",
+ "maasklei"
+ ]
+ },
+ "fdm.p_type_rvo": {
+ "name": "p_type_rvo",
+ "schema": "fdm",
+ "values": [
+ "10",
+ "11",
+ "12",
+ "13",
+ "14",
+ "17",
+ "18",
+ "19",
+ "23",
+ "30",
+ "31",
+ "32",
+ "33",
+ "35",
+ "39",
+ "40",
+ "41",
+ "42",
+ "43",
+ "46",
+ "50",
+ "56",
+ "60",
+ "61",
+ "75",
+ "76",
+ "80",
+ "81",
+ "90",
+ "91",
+ "92",
+ "25",
+ "26",
+ "27",
+ "95",
+ "96",
+ "97",
+ "98",
+ "99",
+ "100",
+ "101",
+ "102",
+ "103",
+ "104",
+ "105",
+ "106",
+ "107",
+ "108",
+ "109",
+ "110",
+ "111",
+ "112",
+ "113",
+ "114",
+ "115",
+ "116",
+ "117",
+ "120"
+ ]
+ }
+ },
+ "schemas": {
+ "fdm": "fdm",
+ "fdm-authn": "fdm-authn",
+ "fdm-authz": "fdm-authz",
+ "fdm-calculator": "fdm-calculator"
+ },
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
diff --git a/fdm-core/src/db/migrations/meta/0022_snapshot.json b/fdm-core/src/db/migrations/meta/0022_snapshot.json
new file mode 100644
index 000000000..aac2827eb
--- /dev/null
+++ b/fdm-core/src/db/migrations/meta/0022_snapshot.json
@@ -0,0 +1,3623 @@
+{
+ "id": "68820e10-7b74-4632-9d86-500508549bb8",
+ "prevId": "1eb64507-01b4-41c6-8583-c114db99b60f",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "fdm.cultivation_catalogue_selecting": {
+ "name": "cultivation_catalogue_selecting",
+ "schema": "fdm",
+ "columns": {
+ "b_id_farm": {
+ "name": "b_id_farm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_lu_source": {
+ "name": "b_lu_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "cultivation_catalogue_selecting_b_id_farm_farms_b_id_farm_fk": {
+ "name": "cultivation_catalogue_selecting_b_id_farm_farms_b_id_farm_fk",
+ "tableFrom": "cultivation_catalogue_selecting",
+ "tableTo": "farms",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id_farm"],
+ "columnsTo": ["b_id_farm"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.cultivation_ending": {
+ "name": "cultivation_ending",
+ "schema": "fdm",
+ "columns": {
+ "b_lu": {
+ "name": "b_lu",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_lu_end": {
+ "name": "b_lu_end",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "m_cropresidue": {
+ "name": "m_cropresidue",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "cultivation_ending_b_lu_cultivations_b_lu_fk": {
+ "name": "cultivation_ending_b_lu_cultivations_b_lu_fk",
+ "tableFrom": "cultivation_ending",
+ "tableTo": "cultivations",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_lu"],
+ "columnsTo": ["b_lu"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.cultivation_harvesting": {
+ "name": "cultivation_harvesting",
+ "schema": "fdm",
+ "columns": {
+ "b_id_harvesting": {
+ "name": "b_id_harvesting",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "b_id_harvestable": {
+ "name": "b_id_harvestable",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_lu": {
+ "name": "b_lu",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_lu_harvest_date": {
+ "name": "b_lu_harvest_date",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "cultivation_harvesting_b_id_harvestable_harvestables_b_id_harvestable_fk": {
+ "name": "cultivation_harvesting_b_id_harvestable_harvestables_b_id_harvestable_fk",
+ "tableFrom": "cultivation_harvesting",
+ "tableTo": "harvestables",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id_harvestable"],
+ "columnsTo": ["b_id_harvestable"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "cultivation_harvesting_b_lu_cultivations_b_lu_fk": {
+ "name": "cultivation_harvesting_b_lu_cultivations_b_lu_fk",
+ "tableFrom": "cultivation_harvesting",
+ "tableTo": "cultivations",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_lu"],
+ "columnsTo": ["b_lu"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.cultivation_starting": {
+ "name": "cultivation_starting",
+ "schema": "fdm",
+ "columns": {
+ "b_id": {
+ "name": "b_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_lu": {
+ "name": "b_lu",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_lu_start": {
+ "name": "b_lu_start",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_sowing_amount": {
+ "name": "b_sowing_amount",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_sowing_method": {
+ "name": "b_sowing_method",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "cultivation_starting_b_id_fields_b_id_fk": {
+ "name": "cultivation_starting_b_id_fields_b_id_fk",
+ "tableFrom": "cultivation_starting",
+ "tableTo": "fields",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id"],
+ "columnsTo": ["b_id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "cultivation_starting_b_lu_cultivations_b_lu_fk": {
+ "name": "cultivation_starting_b_lu_cultivations_b_lu_fk",
+ "tableFrom": "cultivation_starting",
+ "tableTo": "cultivations",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_lu"],
+ "columnsTo": ["b_lu"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.cultivations": {
+ "name": "cultivations",
+ "schema": "fdm",
+ "columns": {
+ "b_lu": {
+ "name": "b_lu",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "b_lu_catalogue": {
+ "name": "b_lu_catalogue",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_lu_variety": {
+ "name": "b_lu_variety",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "b_lu_idx": {
+ "name": "b_lu_idx",
+ "columns": [
+ {
+ "expression": "b_lu",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cultivations_b_lu_catalogue_cultivations_catalogue_b_lu_catalogue_fk": {
+ "name": "cultivations_b_lu_catalogue_cultivations_catalogue_b_lu_catalogue_fk",
+ "tableFrom": "cultivations",
+ "tableTo": "cultivations_catalogue",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_lu_catalogue"],
+ "columnsTo": ["b_lu_catalogue"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.cultivations_catalogue": {
+ "name": "cultivations_catalogue",
+ "schema": "fdm",
+ "columns": {
+ "b_lu_catalogue": {
+ "name": "b_lu_catalogue",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "b_lu_source": {
+ "name": "b_lu_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_lu_name": {
+ "name": "b_lu_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_lu_name_en": {
+ "name": "b_lu_name_en",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_harvestable": {
+ "name": "b_lu_harvestable",
+ "type": "b_lu_harvestable",
+ "typeSchema": "fdm",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_lu_harvestcat": {
+ "name": "b_lu_harvestcat",
+ "type": "b_lu_harvestcat",
+ "typeSchema": "fdm",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_hcat3": {
+ "name": "b_lu_hcat3",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_hcat3_name": {
+ "name": "b_lu_hcat3_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_croprotation": {
+ "name": "b_lu_croprotation",
+ "type": "b_lu_croprotation",
+ "typeSchema": "fdm",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_yield": {
+ "name": "b_lu_yield",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_dm": {
+ "name": "b_lu_dm",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_hi": {
+ "name": "b_lu_hi",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_n_harvestable": {
+ "name": "b_lu_n_harvestable",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_n_residue": {
+ "name": "b_lu_n_residue",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_n_fixation": {
+ "name": "b_n_fixation",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_eom": {
+ "name": "b_lu_eom",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_eom_residues": {
+ "name": "b_lu_eom_residues",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_rest_oravib": {
+ "name": "b_lu_rest_oravib",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_variety_options": {
+ "name": "b_lu_variety_options",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_start_default": {
+ "name": "b_lu_start_default",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_date_harvest_default": {
+ "name": "b_date_harvest_default",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hash": {
+ "name": "hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "b_lu_catalogue_idx": {
+ "name": "b_lu_catalogue_idx",
+ "columns": [
+ {
+ "expression": "b_lu_catalogue",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "b_lu_start_default_format": {
+ "name": "b_lu_start_default_format",
+ "value": "b_lu_start_default IS NULL OR b_lu_start_default ~ '^(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$'"
+ },
+ "b_date_harvest_default_format": {
+ "name": "b_date_harvest_default_format",
+ "value": "b_date_harvest_default IS NULL OR b_date_harvest_default ~ '^(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$'"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "fdm.derogation_applying": {
+ "name": "derogation_applying",
+ "schema": "fdm",
+ "columns": {
+ "b_id_farm": {
+ "name": "b_id_farm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_id_derogation": {
+ "name": "b_id_derogation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "derogation_one_per_farm_per": {
+ "name": "derogation_one_per_farm_per",
+ "columns": [
+ {
+ "expression": "b_id_derogation",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "derogation_applying_b_id_farm_farms_b_id_farm_fk": {
+ "name": "derogation_applying_b_id_farm_farms_b_id_farm_fk",
+ "tableFrom": "derogation_applying",
+ "tableTo": "farms",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id_farm"],
+ "columnsTo": ["b_id_farm"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "derogation_applying_b_id_derogation_derogations_b_id_derogation_fk": {
+ "name": "derogation_applying_b_id_derogation_derogations_b_id_derogation_fk",
+ "tableFrom": "derogation_applying",
+ "tableTo": "derogations",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id_derogation"],
+ "columnsTo": ["b_id_derogation"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.derogations": {
+ "name": "derogations",
+ "schema": "fdm",
+ "columns": {
+ "b_id_derogation": {
+ "name": "b_id_derogation",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "b_derogation_year": {
+ "name": "b_derogation_year",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.farms": {
+ "name": "farms",
+ "schema": "fdm",
+ "columns": {
+ "b_id_farm": {
+ "name": "b_id_farm",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "b_name_farm": {
+ "name": "b_name_farm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_businessid_farm": {
+ "name": "b_businessid_farm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_address_farm": {
+ "name": "b_address_farm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_postalcode_farm": {
+ "name": "b_postalcode_farm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "b_id_farm_idx": {
+ "name": "b_id_farm_idx",
+ "columns": [
+ {
+ "expression": "b_id_farm",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.fertilizer_acquiring": {
+ "name": "fertilizer_acquiring",
+ "schema": "fdm",
+ "columns": {
+ "b_id_farm": {
+ "name": "b_id_farm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "p_id": {
+ "name": "p_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "p_acquiring_amount": {
+ "name": "p_acquiring_amount",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_acquiring_date": {
+ "name": "p_acquiring_date",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "fertilizer_acquiring_b_id_farm_farms_b_id_farm_fk": {
+ "name": "fertilizer_acquiring_b_id_farm_farms_b_id_farm_fk",
+ "tableFrom": "fertilizer_acquiring",
+ "tableTo": "farms",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id_farm"],
+ "columnsTo": ["b_id_farm"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "fertilizer_acquiring_p_id_fertilizers_p_id_fk": {
+ "name": "fertilizer_acquiring_p_id_fertilizers_p_id_fk",
+ "tableFrom": "fertilizer_acquiring",
+ "tableTo": "fertilizers",
+ "schemaTo": "fdm",
+ "columnsFrom": ["p_id"],
+ "columnsTo": ["p_id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.fertilizer_applying": {
+ "name": "fertilizer_applying",
+ "schema": "fdm",
+ "columns": {
+ "p_app_id": {
+ "name": "p_app_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "b_id": {
+ "name": "b_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "p_id": {
+ "name": "p_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "p_app_amount": {
+ "name": "p_app_amount",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_app_method": {
+ "name": "p_app_method",
+ "type": "p_app_method",
+ "typeSchema": "fdm",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_app_date": {
+ "name": "p_app_date",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "p_app_idx": {
+ "name": "p_app_idx",
+ "columns": [
+ {
+ "expression": "p_app_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "fertilizer_applying_b_id_fields_b_id_fk": {
+ "name": "fertilizer_applying_b_id_fields_b_id_fk",
+ "tableFrom": "fertilizer_applying",
+ "tableTo": "fields",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id"],
+ "columnsTo": ["b_id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "fertilizer_applying_p_id_fertilizers_p_id_fk": {
+ "name": "fertilizer_applying_p_id_fertilizers_p_id_fk",
+ "tableFrom": "fertilizer_applying",
+ "tableTo": "fertilizers",
+ "schemaTo": "fdm",
+ "columnsFrom": ["p_id"],
+ "columnsTo": ["p_id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.fertilizer_catalogue_enabling": {
+ "name": "fertilizer_catalogue_enabling",
+ "schema": "fdm",
+ "columns": {
+ "b_id_farm": {
+ "name": "b_id_farm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "p_source": {
+ "name": "p_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "fertilizer_catalogue_enabling_b_id_farm_farms_b_id_farm_fk": {
+ "name": "fertilizer_catalogue_enabling_b_id_farm_farms_b_id_farm_fk",
+ "tableFrom": "fertilizer_catalogue_enabling",
+ "tableTo": "farms",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id_farm"],
+ "columnsTo": ["b_id_farm"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.fertilizer_picking": {
+ "name": "fertilizer_picking",
+ "schema": "fdm",
+ "columns": {
+ "p_id": {
+ "name": "p_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "p_id_catalogue": {
+ "name": "p_id_catalogue",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "p_picking_date": {
+ "name": "p_picking_date",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "fertilizer_picking_p_id_fertilizers_p_id_fk": {
+ "name": "fertilizer_picking_p_id_fertilizers_p_id_fk",
+ "tableFrom": "fertilizer_picking",
+ "tableTo": "fertilizers",
+ "schemaTo": "fdm",
+ "columnsFrom": ["p_id"],
+ "columnsTo": ["p_id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "fertilizer_picking_p_id_catalogue_fertilizers_catalogue_p_id_catalogue_fk": {
+ "name": "fertilizer_picking_p_id_catalogue_fertilizers_catalogue_p_id_catalogue_fk",
+ "tableFrom": "fertilizer_picking",
+ "tableTo": "fertilizers_catalogue",
+ "schemaTo": "fdm",
+ "columnsFrom": ["p_id_catalogue"],
+ "columnsTo": ["p_id_catalogue"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.fertilizers": {
+ "name": "fertilizers",
+ "schema": "fdm",
+ "columns": {
+ "p_id": {
+ "name": "p_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "p_id_idx": {
+ "name": "p_id_idx",
+ "columns": [
+ {
+ "expression": "p_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.fertilizers_catalogue": {
+ "name": "fertilizers_catalogue",
+ "schema": "fdm",
+ "columns": {
+ "p_id_catalogue": {
+ "name": "p_id_catalogue",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "p_source": {
+ "name": "p_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "p_name_nl": {
+ "name": "p_name_nl",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "p_name_en": {
+ "name": "p_name_en",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_description": {
+ "name": "p_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_app_method_options": {
+ "name": "p_app_method_options",
+ "type": "p_app_method[]",
+ "typeSchema": "fdm",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_dm": {
+ "name": "p_dm",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_density": {
+ "name": "p_density",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_om": {
+ "name": "p_om",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_a": {
+ "name": "p_a",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_hc": {
+ "name": "p_hc",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_eom": {
+ "name": "p_eom",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_eoc": {
+ "name": "p_eoc",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_c_rt": {
+ "name": "p_c_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_c_of": {
+ "name": "p_c_of",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_c_if": {
+ "name": "p_c_if",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_c_fr": {
+ "name": "p_c_fr",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_cn_of": {
+ "name": "p_cn_of",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_n_rt": {
+ "name": "p_n_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_n_if": {
+ "name": "p_n_if",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_n_of": {
+ "name": "p_n_of",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_n_wc": {
+ "name": "p_n_wc",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_no3_rt": {
+ "name": "p_no3_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_nh4_rt": {
+ "name": "p_nh4_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_p_rt": {
+ "name": "p_p_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_k_rt": {
+ "name": "p_k_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_mg_rt": {
+ "name": "p_mg_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_ca_rt": {
+ "name": "p_ca_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_ne": {
+ "name": "p_ne",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_s_rt": {
+ "name": "p_s_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_s_wc": {
+ "name": "p_s_wc",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_cu_rt": {
+ "name": "p_cu_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_zn_rt": {
+ "name": "p_zn_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_na_rt": {
+ "name": "p_na_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_si_rt": {
+ "name": "p_si_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_b_rt": {
+ "name": "p_b_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_mn_rt": {
+ "name": "p_mn_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_ni_rt": {
+ "name": "p_ni_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_fe_rt": {
+ "name": "p_fe_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_mo_rt": {
+ "name": "p_mo_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_co_rt": {
+ "name": "p_co_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_as_rt": {
+ "name": "p_as_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_cd_rt": {
+ "name": "p_cd_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_cr_rt": {
+ "name": "p_cr_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_cr_vi": {
+ "name": "p_cr_vi",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_pb_rt": {
+ "name": "p_pb_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_hg_rt": {
+ "name": "p_hg_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_cl_rt": {
+ "name": "p_cl_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_ef_nh3": {
+ "name": "p_ef_nh3",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_type_manure": {
+ "name": "p_type_manure",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_type_mineral": {
+ "name": "p_type_mineral",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_type_compost": {
+ "name": "p_type_compost",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "p_type_rvo": {
+ "name": "p_type_rvo",
+ "type": "p_type_rvo",
+ "typeSchema": "fdm",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hash": {
+ "name": "hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "p_id_catalogue_idx": {
+ "name": "p_id_catalogue_idx",
+ "columns": [
+ {
+ "expression": "p_id_catalogue",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.field_acquiring": {
+ "name": "field_acquiring",
+ "schema": "fdm",
+ "columns": {
+ "b_id": {
+ "name": "b_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_id_farm": {
+ "name": "b_id_farm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_start": {
+ "name": "b_start",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_acquiring_method": {
+ "name": "b_acquiring_method",
+ "type": "b_acquiring_method",
+ "typeSchema": "fdm",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'unknown'"
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "field_acquiring_b_id_fields_b_id_fk": {
+ "name": "field_acquiring_b_id_fields_b_id_fk",
+ "tableFrom": "field_acquiring",
+ "tableTo": "fields",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id"],
+ "columnsTo": ["b_id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "field_acquiring_b_id_farm_farms_b_id_farm_fk": {
+ "name": "field_acquiring_b_id_farm_farms_b_id_farm_fk",
+ "tableFrom": "field_acquiring",
+ "tableTo": "farms",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id_farm"],
+ "columnsTo": ["b_id_farm"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.field_discarding": {
+ "name": "field_discarding",
+ "schema": "fdm",
+ "columns": {
+ "b_id": {
+ "name": "b_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_end": {
+ "name": "b_end",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "field_discarding_b_id_fields_b_id_fk": {
+ "name": "field_discarding_b_id_fields_b_id_fk",
+ "tableFrom": "field_discarding",
+ "tableTo": "fields",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id"],
+ "columnsTo": ["b_id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.fields": {
+ "name": "fields",
+ "schema": "fdm",
+ "columns": {
+ "b_id": {
+ "name": "b_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "b_name": {
+ "name": "b_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_geometry": {
+ "name": "b_geometry",
+ "type": "geometry(Polygon,4326)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_id_source": {
+ "name": "b_id_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_bufferstrip": {
+ "name": "b_bufferstrip",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "b_id_idx": {
+ "name": "b_id_idx",
+ "columns": [
+ {
+ "expression": "b_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "b_geom_idx": {
+ "name": "b_geom_idx",
+ "columns": [
+ {
+ "expression": "b_geometry",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "gist",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.harvestable_analyses": {
+ "name": "harvestable_analyses",
+ "schema": "fdm",
+ "columns": {
+ "b_id_harvestable_analysis": {
+ "name": "b_id_harvestable_analysis",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "b_lu_yield": {
+ "name": "b_lu_yield",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_yield_fresh": {
+ "name": "b_lu_yield_fresh",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_yield_bruto": {
+ "name": "b_lu_yield_bruto",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_tarra": {
+ "name": "b_lu_tarra",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_dm": {
+ "name": "b_lu_dm",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_moist": {
+ "name": "b_lu_moist",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_uww": {
+ "name": "b_lu_uww",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_cp": {
+ "name": "b_lu_cp",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_n_harvestable": {
+ "name": "b_lu_n_harvestable",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_n_residue": {
+ "name": "b_lu_n_residue",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_p_harvestable": {
+ "name": "b_lu_p_harvestable",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_p_residue": {
+ "name": "b_lu_p_residue",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_k_harvestable": {
+ "name": "b_lu_k_harvestable",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_lu_k_residue": {
+ "name": "b_lu_k_residue",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "b_id_harvestable_analyses_idx": {
+ "name": "b_id_harvestable_analyses_idx",
+ "columns": [
+ {
+ "expression": "b_id_harvestable_analysis",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.harvestable_sampling": {
+ "name": "harvestable_sampling",
+ "schema": "fdm",
+ "columns": {
+ "b_id_harvestable": {
+ "name": "b_id_harvestable",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_id_harvestable_analysis": {
+ "name": "b_id_harvestable_analysis",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_sampling_date": {
+ "name": "b_sampling_date",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "harvestable_sampling_b_id_harvestable_harvestables_b_id_harvestable_fk": {
+ "name": "harvestable_sampling_b_id_harvestable_harvestables_b_id_harvestable_fk",
+ "tableFrom": "harvestable_sampling",
+ "tableTo": "harvestables",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id_harvestable"],
+ "columnsTo": ["b_id_harvestable"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "harvestable_sampling_b_id_harvestable_analysis_harvestable_analyses_b_id_harvestable_analysis_fk": {
+ "name": "harvestable_sampling_b_id_harvestable_analysis_harvestable_analyses_b_id_harvestable_analysis_fk",
+ "tableFrom": "harvestable_sampling",
+ "tableTo": "harvestable_analyses",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id_harvestable_analysis"],
+ "columnsTo": ["b_id_harvestable_analysis"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.harvestables": {
+ "name": "harvestables",
+ "schema": "fdm",
+ "columns": {
+ "b_id_harvestable": {
+ "name": "b_id_harvestable",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "b_id_harvestable_idx": {
+ "name": "b_id_harvestable_idx",
+ "columns": [
+ {
+ "expression": "b_id_harvestable",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.intending_grazing": {
+ "name": "intending_grazing",
+ "schema": "fdm",
+ "columns": {
+ "b_id_farm": {
+ "name": "b_id_farm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_grazing_intention": {
+ "name": "b_grazing_intention",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_grazing_intention_year": {
+ "name": "b_grazing_intention_year",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "intending_grazing_b_id_farm_farms_b_id_farm_fk": {
+ "name": "intending_grazing_b_id_farm_farms_b_id_farm_fk",
+ "tableFrom": "intending_grazing",
+ "tableTo": "farms",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id_farm"],
+ "columnsTo": ["b_id_farm"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "intending_grazing_b_id_farm_b_grazing_intention_year_pk": {
+ "name": "intending_grazing_b_id_farm_b_grazing_intention_year_pk",
+ "columns": ["b_id_farm", "b_grazing_intention_year"]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.organic_certifications": {
+ "name": "organic_certifications",
+ "schema": "fdm",
+ "columns": {
+ "b_id_organic": {
+ "name": "b_id_organic",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "b_organic_traces": {
+ "name": "b_organic_traces",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_organic_skal": {
+ "name": "b_organic_skal",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_organic_issued": {
+ "name": "b_organic_issued",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_organic_expires": {
+ "name": "b_organic_expires",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.organic_certifications_holding": {
+ "name": "organic_certifications_holding",
+ "schema": "fdm",
+ "columns": {
+ "b_id_farm": {
+ "name": "b_id_farm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "b_id_organic": {
+ "name": "b_id_organic",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "organic_one_farm_per_cert": {
+ "name": "organic_one_farm_per_cert",
+ "columns": [
+ {
+ "expression": "b_id_organic",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "organic_certifications_holding_b_id_farm_farms_b_id_farm_fk": {
+ "name": "organic_certifications_holding_b_id_farm_farms_b_id_farm_fk",
+ "tableFrom": "organic_certifications_holding",
+ "tableTo": "farms",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id_farm"],
+ "columnsTo": ["b_id_farm"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "organic_certifications_holding_b_id_organic_organic_certifications_b_id_organic_fk": {
+ "name": "organic_certifications_holding_b_id_organic_organic_certifications_b_id_organic_fk",
+ "tableFrom": "organic_certifications_holding",
+ "tableTo": "organic_certifications",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id_organic"],
+ "columnsTo": ["b_id_organic"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.soil_analysis": {
+ "name": "soil_analysis",
+ "schema": "fdm",
+ "columns": {
+ "a_id": {
+ "name": "a_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "a_date": {
+ "name": "a_date",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_source": {
+ "name": "a_source",
+ "type": "a_source",
+ "typeSchema": "fdm",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'other'"
+ },
+ "a_al_ox": {
+ "name": "a_al_ox",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_c_of": {
+ "name": "a_c_of",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_ca_co": {
+ "name": "a_ca_co",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_ca_co_po": {
+ "name": "a_ca_co_po",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_caco3_if": {
+ "name": "a_caco3_if",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_cec_co": {
+ "name": "a_cec_co",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_clay_mi": {
+ "name": "a_clay_mi",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_cn_fr": {
+ "name": "a_cn_fr",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_com_fr": {
+ "name": "a_com_fr",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_cu_cc": {
+ "name": "a_cu_cc",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_density_sa": {
+ "name": "a_density_sa",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_fe_ox": {
+ "name": "a_fe_ox",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_k_cc": {
+ "name": "a_k_cc",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_k_co": {
+ "name": "a_k_co",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_k_co_po": {
+ "name": "a_k_co_po",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_mg_cc": {
+ "name": "a_mg_cc",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_mg_co": {
+ "name": "a_mg_co",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_mg_co_po": {
+ "name": "a_mg_co_po",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_n_pmn": {
+ "name": "a_n_pmn",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_n_rt": {
+ "name": "a_n_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_nh4_cc": {
+ "name": "a_nh4_cc",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_nmin_cc": {
+ "name": "a_nmin_cc",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_no3_cc": {
+ "name": "a_no3_cc",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_p_al": {
+ "name": "a_p_al",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_p_cc": {
+ "name": "a_p_cc",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_p_ox": {
+ "name": "a_p_ox",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_p_rt": {
+ "name": "a_p_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_p_sg": {
+ "name": "a_p_sg",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_p_wa": {
+ "name": "a_p_wa",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_ph_cc": {
+ "name": "a_ph_cc",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_s_rt": {
+ "name": "a_s_rt",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_sand_mi": {
+ "name": "a_sand_mi",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_silt_mi": {
+ "name": "a_silt_mi",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_som_loi": {
+ "name": "a_som_loi",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "a_zn_cc": {
+ "name": "a_zn_cc",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_gwl_class": {
+ "name": "b_gwl_class",
+ "type": "b_gwl_class",
+ "typeSchema": "fdm",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_soiltype_agr": {
+ "name": "b_soiltype_agr",
+ "type": "b_soiltype_agr",
+ "typeSchema": "fdm",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm.soil_sampling": {
+ "name": "soil_sampling",
+ "schema": "fdm",
+ "columns": {
+ "b_id_sampling": {
+ "name": "b_id_sampling",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "b_id": {
+ "name": "b_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "a_id": {
+ "name": "a_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "a_depth_upper": {
+ "name": "a_depth_upper",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "a_depth_lower": {
+ "name": "a_depth_lower",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_sampling_date": {
+ "name": "b_sampling_date",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "b_sampling_geometry": {
+ "name": "b_sampling_geometry",
+ "type": "geometry(MultiPoint,4326)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated": {
+ "name": "updated",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "soil_sampling_b_id_fields_b_id_fk": {
+ "name": "soil_sampling_b_id_fields_b_id_fk",
+ "tableFrom": "soil_sampling",
+ "tableTo": "fields",
+ "schemaTo": "fdm",
+ "columnsFrom": ["b_id"],
+ "columnsTo": ["b_id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "soil_sampling_a_id_soil_analysis_a_id_fk": {
+ "name": "soil_sampling_a_id_soil_analysis_a_id_fk",
+ "tableFrom": "soil_sampling",
+ "tableTo": "soil_analysis",
+ "schemaTo": "fdm",
+ "columnsFrom": ["a_id"],
+ "columnsTo": ["a_id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm-authn.account": {
+ "name": "account",
+ "schema": "fdm-authn",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password": {
+ "name": "password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "account_userId_idx": {
+ "name": "account_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "account_user_id_user_id_fk": {
+ "name": "account_user_id_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "schemaTo": "fdm-authn",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm-authn.invitation": {
+ "name": "invitation",
+ "schema": "fdm-authn",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "inviter_id": {
+ "name": "inviter_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "invitation_organizationId_idx": {
+ "name": "invitation_organizationId_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "invitation_email_idx": {
+ "name": "invitation_email_idx",
+ "columns": [
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "invitation_organization_id_organization_id_fk": {
+ "name": "invitation_organization_id_organization_id_fk",
+ "tableFrom": "invitation",
+ "tableTo": "organization",
+ "schemaTo": "fdm-authn",
+ "columnsFrom": ["organization_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "invitation_inviter_id_user_id_fk": {
+ "name": "invitation_inviter_id_user_id_fk",
+ "tableFrom": "invitation",
+ "tableTo": "user",
+ "schemaTo": "fdm-authn",
+ "columnsFrom": ["inviter_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm-authn.member": {
+ "name": "member",
+ "schema": "fdm-authn",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "member_organizationId_idx": {
+ "name": "member_organizationId_idx",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "member_userId_idx": {
+ "name": "member_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "member_organization_id_organization_id_fk": {
+ "name": "member_organization_id_organization_id_fk",
+ "tableFrom": "member",
+ "tableTo": "organization",
+ "schemaTo": "fdm-authn",
+ "columnsFrom": ["organization_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "member_user_id_user_id_fk": {
+ "name": "member_user_id_user_id_fk",
+ "tableFrom": "member",
+ "tableTo": "user",
+ "schemaTo": "fdm-authn",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm-authn.organization": {
+ "name": "organization",
+ "schema": "fdm-authn",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "logo": {
+ "name": "logo",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "organization_slug_uidx": {
+ "name": "organization_slug_uidx",
+ "columns": [
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "organization_slug_unique": {
+ "name": "organization_slug_unique",
+ "nullsNotDistinct": false,
+ "columns": ["slug"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm-authn.rate_limit": {
+ "name": "rate_limit",
+ "schema": "fdm-authn",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "count": {
+ "name": "count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_request": {
+ "name": "last_request",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm-authn.session": {
+ "name": "session",
+ "schema": "fdm-authn",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "active_organization_id": {
+ "name": "active_organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "session_userId_idx": {
+ "name": "session_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "session_user_id_user_id_fk": {
+ "name": "session_user_id_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "schemaTo": "fdm-authn",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "session_token_unique": {
+ "name": "session_token_unique",
+ "nullsNotDistinct": false,
+ "columns": ["token"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm-authn.user": {
+ "name": "user",
+ "schema": "fdm-authn",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email_verified": {
+ "name": "email_verified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "username": {
+ "name": "username",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "display_username": {
+ "name": "display_username",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "firstname": {
+ "name": "firstname",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "surname": {
+ "name": "surname",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lang": {
+ "name": "lang",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'nl-NL'"
+ },
+ "farm_active": {
+ "name": "farm_active",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": ["email"]
+ },
+ "user_username_unique": {
+ "name": "user_username_unique",
+ "nullsNotDistinct": false,
+ "columns": ["username"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm-authn.verification": {
+ "name": "verification",
+ "schema": "fdm-authn",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "verification_identifier_idx": {
+ "name": "verification_identifier_idx",
+ "columns": [
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm-authz.audit": {
+ "name": "audit",
+ "schema": "fdm-authz",
+ "columns": {
+ "audit_id": {
+ "name": "audit_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "audit_timestamp": {
+ "name": "audit_timestamp",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "audit_origin": {
+ "name": "audit_origin",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "principal_id": {
+ "name": "principal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_resource": {
+ "name": "target_resource",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_resource_id": {
+ "name": "target_resource_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "granting_resource": {
+ "name": "granting_resource",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "granting_resource_id": {
+ "name": "granting_resource_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "allowed": {
+ "name": "allowed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "duration": {
+ "name": "duration",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm-authz.role": {
+ "name": "role",
+ "schema": "fdm-authz",
+ "columns": {
+ "role_id": {
+ "name": "role_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "resource": {
+ "name": "resource",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resource_id": {
+ "name": "resource_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "principal_id": {
+ "name": "principal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created": {
+ "name": "created",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "deleted": {
+ "name": "deleted",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "role_idx": {
+ "name": "role_idx",
+ "columns": [
+ {
+ "expression": "resource",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "resource_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "principal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "role",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "deleted",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm-calculator.calculation_cache": {
+ "name": "calculation_cache",
+ "schema": "fdm-calculator",
+ "columns": {
+ "calculation_hash": {
+ "name": "calculation_hash",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "calculation_function": {
+ "name": "calculation_function",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "calculator_version": {
+ "name": "calculator_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "input": {
+ "name": "input",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "result": {
+ "name": "result",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "fdm-calculator.calculation_errors": {
+ "name": "calculation_errors",
+ "schema": "fdm-calculator",
+ "columns": {
+ "calculation_error_id": {
+ "name": "calculation_error_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "calculation_function": {
+ "name": "calculation_function",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "calculator_version": {
+ "name": "calculator_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "input": {
+ "name": "input",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_message": {
+ "name": "error_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stack_trace": {
+ "name": "stack_trace",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {
+ "fdm.b_acquiring_method": {
+ "name": "b_acquiring_method",
+ "schema": "fdm",
+ "values": [
+ "nl_01",
+ "nl_02",
+ "nl_03",
+ "nl_04",
+ "nl_07",
+ "nl_09",
+ "nl_10",
+ "nl_11",
+ "nl_12",
+ "nl_13",
+ "nl_61",
+ "nl_63",
+ "unknown"
+ ]
+ },
+ "fdm.p_app_method": {
+ "name": "p_app_method",
+ "schema": "fdm",
+ "values": [
+ "slotted coulter",
+ "incorporation",
+ "incorporation 2 tracks",
+ "injection",
+ "shallow injection",
+ "spraying",
+ "broadcasting",
+ "spoke wheel",
+ "pocket placement",
+ "narrowband"
+ ]
+ },
+ "fdm.b_gwl_class": {
+ "name": "b_gwl_class",
+ "schema": "fdm",
+ "values": [
+ "I",
+ "Ia",
+ "Ic",
+ "II",
+ "IIa",
+ "IIb",
+ "IIc",
+ "III",
+ "IIIa",
+ "IIIb",
+ "IV",
+ "IVu",
+ "IVc",
+ "V",
+ "Va",
+ "Vao",
+ "Vad",
+ "Vb",
+ "Vbo",
+ "Vbd",
+ "sV",
+ "sVb",
+ "VI",
+ "VIo",
+ "VId",
+ "VII",
+ "VIIo",
+ "VIId",
+ "VIII",
+ "VIIIo",
+ "VIIId"
+ ]
+ },
+ "fdm.b_lu_harvestcat": {
+ "name": "b_lu_harvestcat",
+ "schema": "fdm",
+ "values": [
+ "HC010",
+ "HC020",
+ "HC031",
+ "HC040",
+ "HC041",
+ "HC042",
+ "HC050"
+ ]
+ },
+ "fdm.b_lu_harvestable": {
+ "name": "b_lu_harvestable",
+ "schema": "fdm",
+ "values": ["none", "once", "multiple"]
+ },
+ "fdm.b_lu_croprotation": {
+ "name": "b_lu_croprotation",
+ "schema": "fdm",
+ "values": [
+ "other",
+ "clover",
+ "nature",
+ "potato",
+ "grass",
+ "rapeseed",
+ "starch",
+ "maize",
+ "cereal",
+ "sugarbeet",
+ "alfalfa",
+ "catchcrop"
+ ]
+ },
+ "fdm.a_source": {
+ "name": "a_source",
+ "schema": "fdm",
+ "values": [
+ "nl-rva-l122",
+ "nl-rva-l136",
+ "nl-rva-l264",
+ "nl-rva-l320",
+ "nl-rva-l335",
+ "nl-rva-l610",
+ "nl-rva-l648",
+ "nl-rva-l697",
+ "nl-other-nmi",
+ "other"
+ ]
+ },
+ "fdm.b_soiltype_agr": {
+ "name": "b_soiltype_agr",
+ "schema": "fdm",
+ "values": [
+ "moerige_klei",
+ "rivierklei",
+ "dekzand",
+ "zeeklei",
+ "dalgrond",
+ "veen",
+ "loess",
+ "duinzand",
+ "maasklei"
+ ]
+ },
+ "fdm.p_type_rvo": {
+ "name": "p_type_rvo",
+ "schema": "fdm",
+ "values": [
+ "10",
+ "11",
+ "12",
+ "13",
+ "14",
+ "17",
+ "18",
+ "19",
+ "23",
+ "30",
+ "31",
+ "32",
+ "33",
+ "35",
+ "39",
+ "40",
+ "41",
+ "42",
+ "43",
+ "46",
+ "50",
+ "56",
+ "60",
+ "61",
+ "75",
+ "76",
+ "80",
+ "81",
+ "90",
+ "91",
+ "92",
+ "25",
+ "26",
+ "27",
+ "95",
+ "96",
+ "97",
+ "98",
+ "99",
+ "100",
+ "101",
+ "102",
+ "103",
+ "104",
+ "105",
+ "106",
+ "107",
+ "108",
+ "109",
+ "110",
+ "111",
+ "112",
+ "113",
+ "114",
+ "115",
+ "116",
+ "117",
+ "120"
+ ]
+ }
+ },
+ "schemas": {
+ "fdm": "fdm",
+ "fdm-authn": "fdm-authn",
+ "fdm-authz": "fdm-authz",
+ "fdm-calculator": "fdm-calculator"
+ },
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
diff --git a/fdm-core/src/db/migrations/meta/_journal.json b/fdm-core/src/db/migrations/meta/_journal.json
index 26da9ff47..bb7adc0c0 100644
--- a/fdm-core/src/db/migrations/meta/_journal.json
+++ b/fdm-core/src/db/migrations/meta/_journal.json
@@ -148,6 +148,20 @@
"when": 1767697779747,
"tag": "0020_thick_zodiak",
"breakpoints": true
+ },
+ {
+ "idx": 21,
+ "version": "7",
+ "when": 1768485087752,
+ "tag": "0021_exotic_mesmero",
+ "breakpoints": true
+ },
+ {
+ "idx": 22,
+ "version": "7",
+ "when": 1768485087753,
+ "tag": "0022_calculate_bufferstrips",
+ "breakpoints": true
}
]
}
diff --git a/fdm-core/src/db/schema.ts b/fdm-core/src/db/schema.ts
index 721062bbe..016c9ce8d 100644
--- a/fdm-core/src/db/schema.ts
+++ b/fdm-core/src/db/schema.ts
@@ -98,6 +98,7 @@ export const fields = fdmSchema.table(
type: "Polygon",
}), // PGLite does not support PostGIS yet; I expect to be supported in Q4 2024: https://github.com/electric-sql/pglite/issues/11
b_id_source: text(),
+ b_bufferstrip: boolean().notNull().default(false),
created: timestamp({ withTimezone: true }).notNull().defaultNow(),
updated: timestamp({ withTimezone: true }),
},
diff --git a/fdm-core/src/field.d.ts b/fdm-core/src/field.d.ts
index 4d7bbb72f..cf9d07f7a 100644
--- a/fdm-core/src/field.d.ts
+++ b/fdm-core/src/field.d.ts
@@ -12,5 +12,5 @@ export interface Field {
b_start: schema.fieldAcquiringTypeSelect["b_start"]
b_end: schema.fieldDiscardingTypeSelect["b_end"]
b_acquiring_method: schema.fieldAcquiringTypeSelect["b_acquiring_method"]
- b_isproductive: boolean | null
+ b_bufferstrip: schema.fieldsTypeSelect["b_bufferstrip"]
}
diff --git a/fdm-core/src/field.test.ts b/fdm-core/src/field.test.ts
index ab4896e47..75f5bbac9 100644
--- a/fdm-core/src/field.test.ts
+++ b/fdm-core/src/field.test.ts
@@ -9,7 +9,7 @@ import { createFdmServer } from "./fdm-server"
import type { FdmServerType } from "./fdm-server.d"
import {
addField,
- determineIfFieldIsProductive,
+ determineIfFieldIsBuffer,
getField,
getFields,
listAvailableAcquiringMethods,
@@ -106,7 +106,7 @@ describe("Farm Data Model", () => {
expect(field.b_centroid[1]).toBeTypeOf("number")
expect(field.b_area).toBeGreaterThan(0)
expect(field.b_perimeter).toBeGreaterThan(0)
- expect(field.b_isproductive).toBe(true)
+ expect(field.b_bufferstrip).toBe(false)
expect(field.b_start).toEqual(AcquireDate)
expect(field.b_end).toEqual(discardingDate)
expect(field.b_acquiring_method).toBe(AcquiringMethod)
@@ -238,7 +238,7 @@ describe("Farm Data Model", () => {
)
for (const field of fields) {
expect(field.b_perimeter).toBeGreaterThan(0)
- expect(field.b_isproductive).toBe(true)
+ expect(field.b_bufferstrip).toBe(false)
}
})
@@ -379,7 +379,7 @@ describe("Farm Data Model", () => {
expect(fields1.length).toBe(1)
expect(fields1[0].b_name).toBe(field2Name)
expect(fields1[0].b_perimeter).toBeGreaterThan(0)
- expect(fields1[0].b_isproductive).toBe(true)
+ expect(fields1[0].b_bufferstrip).toBe(false)
// Test with a timeframe that includes both Field 1 and Field 2
const timeframe2 = {
@@ -398,7 +398,7 @@ describe("Farm Data Model", () => {
)
for (const field of fields2) {
expect(field.b_perimeter).toBeGreaterThan(0)
- expect(field.b_isproductive).toBe(true)
+ expect(field.b_bufferstrip).toBe(false)
}
// Test with a timeframe that includes field 2 and field 3
@@ -419,7 +419,7 @@ describe("Farm Data Model", () => {
)
for (const field of fields3) {
expect(field.b_perimeter).toBeGreaterThan(0)
- expect(field.b_isproductive).toBe(true)
+ expect(field.b_bufferstrip).toBe(false)
}
//Test with only start date
const fields4 = await getFields(fdm, principal_id, b_id_farm, {
@@ -437,7 +437,7 @@ describe("Farm Data Model", () => {
)
for (const field of fields4) {
expect(field.b_perimeter).toBeGreaterThan(0)
- expect(field.b_isproductive).toBe(true)
+ expect(field.b_bufferstrip).toBe(false)
}
//Test with only end date
const fields5 = await getFields(fdm, principal_id, b_id_farm, {
@@ -450,7 +450,7 @@ describe("Farm Data Model", () => {
)
for (const field of fields5) {
expect(field.b_perimeter).toBeGreaterThan(0)
- expect(field.b_isproductive).toBe(true)
+ expect(field.b_bufferstrip).toBe(false)
}
})
})
@@ -721,7 +721,7 @@ describe("Farm Data Model", () => {
expect(field.b_name).toBe(fieldName)
expect(field.b_perimeter).toBeGreaterThan(0)
expect(field.b_perimeter).toBeGreaterThan(4000000)
- expect(field.b_isproductive).toBe(true)
+ expect(field.b_bufferstrip).toBe(false)
})
})
@@ -960,47 +960,31 @@ describe("Farm Data Model", () => {
})
})
- describe("determineIfFieldIsProductive", () => {
- it("should determine if a field is productive by checking name", async () => {
- const b_isproductive = determineIfFieldIsProductive(
- 1.0,
- 100.0,
- "Bufferstrip",
- )
- expect(b_isproductive).toBe(false)
+ describe("determineIfFieldIsBuffer", () => {
+ it("should determine if a field is buffer by checking name", async () => {
+ const isBuffer = determineIfFieldIsBuffer(1.0, 100.0, "Bufferstrip")
+ expect(isBuffer).toBe(true)
})
- it("should determine if a field is productive by checking shape", async () => {
- const b_isproductive = determineIfFieldIsProductive(
- 1.0,
- 10000.0,
- "Field",
- )
- expect(b_isproductive).toBe(false)
+ it("should determine if a field is buffer by checking shape", async () => {
+ const isBuffer = determineIfFieldIsBuffer(1.0, 10000.0, "Field")
+ expect(isBuffer).toBe(true)
})
- it("should determine if a field is productive by checking shape (area is large enough)", async () => {
- const b_isproductive = determineIfFieldIsProductive(
- 2.5,
- 10000.0,
- "Field",
- )
- expect(b_isproductive).toBe(true)
+ it("should determine if a field is productive (not buffer) by checking shape (area is large enough)", async () => {
+ const isBuffer = determineIfFieldIsBuffer(2.5, 10000.0, "Field")
+ expect(isBuffer).toBe(false)
})
- it("should determine if a field is productive by checking shape and name", async () => {
- const b_isproductive = determineIfFieldIsProductive(
+ it("should determine if a field is buffer by checking shape and name", async () => {
+ const isBuffer = determineIfFieldIsBuffer(
1.0,
1000.0,
"Bufferstrip",
)
- expect(b_isproductive).toBe(false)
+ expect(isBuffer).toBe(true)
})
- it("should determine if a field is productive by checking shape and name (productive)", async () => {
- const b_isproductive = determineIfFieldIsProductive(
- 10.0,
- 100.0,
- "Field",
- )
- expect(b_isproductive).toBe(true)
+ it("should determine if a field is buffer by checking shape and name (productive)", async () => {
+ const isBuffer = determineIfFieldIsBuffer(10.0, 100.0, "Field")
+ expect(isBuffer).toBe(false)
})
})
diff --git a/fdm-core/src/field.ts b/fdm-core/src/field.ts
index eb15abb9e..5d1704c73 100644
--- a/fdm-core/src/field.ts
+++ b/fdm-core/src/field.ts
@@ -53,6 +53,7 @@ export async function addField(
b_start: schema.fieldAcquiringTypeInsert["b_start"],
b_acquiring_method: schema.fieldAcquiringTypeInsert["b_acquiring_method"],
b_end?: schema.fieldDiscardingTypeInsert["b_end"],
+ b_bufferstrip?: schema.fieldsTypeInsert["b_bufferstrip"],
): Promise {
try {
await checkPermission(
@@ -74,6 +75,7 @@ export async function addField(
b_name: b_name,
b_id_source: b_id_source,
b_geometry: b_geometry,
+ b_bufferstrip: b_bufferstrip ?? false,
}
await tx.insert(schema.fields).values(fieldData)
@@ -111,6 +113,34 @@ export async function addField(
}
await tx.insert(schema.fieldDiscarding).values(fieldDiscardingData)
+ // If buffer status is not provided try to determine
+ if (b_bufferstrip === undefined) {
+ const field = await tx
+ .select({
+ b_id: schema.fields.b_id,
+ b_name: schema.fields.b_name,
+ b_geometry: schema.fields.b_geometry,
+ b_area: sql`ROUND((ST_Area(b_geometry::geography)/10000)::NUMERIC, 2)::FLOAT`,
+ b_perimeter: sql`ROUND((ST_Length(ST_ExteriorRing(b_geometry)::geography))::NUMERIC, 2)::FLOAT`,
+ })
+ .from(schema.fields)
+ .where(eq(schema.fields.b_id, b_id))
+ .limit(1)
+
+ if (field.length > 0) {
+ const isBuffer = determineIfFieldIsBuffer(
+ field[0].b_area,
+ field[0].b_perimeter,
+ field[0].b_name,
+ )
+
+ await tx
+ .update(schema.fields)
+ .set({ b_bufferstrip: isBuffer })
+ .where(eq(schema.fields.b_id, b_id))
+ }
+ }
+
return b_id
})
} catch (err) {
@@ -122,6 +152,7 @@ export async function addField(
b_start,
b_acquiring_method,
b_end,
+ b_bufferstrip,
})
}
}
@@ -163,6 +194,7 @@ export async function getField(
b_id_farm: schema.fieldAcquiring.b_id_farm,
b_id_source: schema.fields.b_id_source,
b_geometry: schema.fields.b_geometry,
+ b_bufferstrip: schema.fields.b_bufferstrip,
b_centroid_x: sql`ST_X(ST_Centroid(b_geometry))`,
b_centroid_y: sql`ST_Y(ST_Centroid(b_geometry))`,
b_area: sql`ROUND((ST_Area(b_geometry::geography)/10000)::NUMERIC, 2)::FLOAT`,
@@ -187,11 +219,6 @@ export async function getField(
field[0].b_centroid = [field[0].b_centroid_x, field[0].b_centroid_y]
field[0].b_centroid_x = undefined
field[0].b_centroid_y = undefined
- field[0].b_isproductive = determineIfFieldIsProductive(
- field[0].b_area,
- field[0].b_perimeter,
- field[0].b_name,
- )
return field[0]
} catch (err) {
@@ -276,6 +303,7 @@ export async function getFields(
b_id_farm: schema.fieldAcquiring.b_id_farm,
b_id_source: schema.fields.b_id_source,
b_geometry: schema.fields.b_geometry,
+ b_bufferstrip: schema.fields.b_bufferstrip,
b_centroid_x: sql`ST_X(ST_Centroid(b_geometry))`,
b_centroid_y: sql`ST_Y(ST_Centroid(b_geometry))`,
b_area: sql`ROUND((ST_Area(b_geometry::geography)/10000)::NUMERIC, 2)::FLOAT`,
@@ -301,11 +329,6 @@ export async function getFields(
field.b_centroid = [field.b_centroid_x, field.b_centroid_y]
field.b_centroid_x = undefined
field.b_centroid_y = undefined
- field.b_isproductive = determineIfFieldIsProductive(
- field.b_area,
- field.b_perimeter,
- field.b_name,
- )
}
return fields
@@ -344,6 +367,7 @@ export async function updateField(
b_start?: schema.fieldAcquiringTypeInsert["b_start"],
b_acquiring_method?: schema.fieldAcquiringTypeInsert["b_acquiring_method"],
b_end?: schema.fieldDiscardingTypeInsert["b_end"],
+ b_bufferstrip?: schema.fieldsTypeInsert["b_bufferstrip"],
): Promise {
return await fdm.transaction(async (tx: FdmType) => {
try {
@@ -368,6 +392,9 @@ export async function updateField(
if (b_geometry !== undefined) {
setFields.b_geometry = b_geometry
}
+ if (b_bufferstrip !== undefined) {
+ setFields.b_bufferstrip = b_bufferstrip
+ }
setFields.updated = updated
await tx
@@ -409,6 +436,7 @@ export async function updateField(
b_id_farm: schema.fieldAcquiring.b_id_farm,
b_id_source: schema.fields.b_id_source,
b_geometry: schema.fields.b_geometry,
+ b_bufferstrip: schema.fields.b_bufferstrip,
b_start: schema.fieldAcquiring.b_start,
b_acquiring_method:
schema.fieldAcquiring.b_acquiring_method,
@@ -427,11 +455,12 @@ export async function updateField(
)
.where(eq(schema.fields.b_id, b_id))
.limit(1)
- const field = result[0]
+ const field = result[0] as unknown as Field
// Check if acquiring date is before discarding date
if (
field.b_end &&
+ field.b_start &&
field.b_start.getTime() >= field.b_end.getTime()
) {
throw new Error("Acquiring date must be before discarding date")
@@ -652,34 +681,38 @@ export function listAvailableAcquiringMethods(): {
}
/**
- * Determines if a field is considered productive based on its area, perimeter, and name.
+ * Determines if a field is considered a buffer based on its area, perimeter, and name.
*
- * This function uses two heuristics to differentiate between productive fields and non-productive areas like buffer strips:
- * 1. Shape-based: A field is classified as non-productive if its area is less than 2.5 hectares and the ratio of its perimeter
+ * This function uses two heuristics to differentiate between productive fields and buffer strips:
+ * 1. Shape-based: A field is classified as buffer if its area is less than 2.5 hectares and the ratio of its perimeter
* to the square root of its area (in square meters) is greater than or equal to a predefined constant (20).
- * 2. Name-based: A field is classified as non-productive if its name contains "buffer" (case-insensitive).
+ * 2. Name-based: A field is classified as buffer if its name contains "buffer" (case-insensitive).
*
- * A field is considered productive only if both checks pass.
+ * A field is considered buffer only if one of the checks pass.
*
* @param b_area The area of the field in hectares.
* @param b_perimeter The perimeter of the field in meters.
* @param b_name The name of the field.
- * @returns `true` if the field is determined to be productive, `false` otherwise.
+ * @returns `true` if the field is determined to be buffer, `false` otherwise.
* @alpha
*/
-export function determineIfFieldIsProductive(
+export function determineIfFieldIsBuffer(
b_area: number,
b_perimeter: number,
b_name: schema.fieldsTypeSelect["b_name"],
) {
+ if (!b_area || b_area <= 0 || !b_perimeter || b_perimeter <= 0) {
+ return (b_name ?? "").toLowerCase().includes("buffer")
+ }
+
// Sven found that a ratio for a field with Perimeter (m) / SQRT(Area (m^2)) usually differentiates buffferstrips from "normal" fields when the ratio is larger than 20 and area smaller than 2.5 ha
const BUFFERSTROKEN_CONSTANT = 20
- const productiveAssumedByShape =
- b_perimeter / Math.sqrt(b_area * 10000) < BUFFERSTROKEN_CONSTANT ||
- b_area >= 2.5
+ const bufferAssumedByShape =
+ b_perimeter / Math.sqrt(b_area * 10000) >= BUFFERSTROKEN_CONSTANT &&
+ b_area < 2.5
// Check if name contains 'buffer'
- const productiveAssumedByName = !b_name.toLowerCase().includes("buffer")
+ const bufferAssumedByName = (b_name ?? "").toLowerCase().includes("buffer")
- return productiveAssumedByShape && productiveAssumedByName
+ return bufferAssumedByShape || bufferAssumedByName
}