batch_stage_details

-1 rows


Description

Current inventory and latest observed quantities for each stage of a nursery batch.

Columns

Column Type Size Nulls Auto Default Children Parents Comments
batch_id int8 19 null
batches.id batch_stage_details_batch_id_fkey C
stage_id int4 10 null
batch_stages.id batch_stage_details_stage_id_fkey C
quantity int4 10 null

Number of seedlings currently available in this stage. Withdrawals cause this to decrease.

latest_observed_quantity int4 10 null

Latest user-observed number of seedlings in this stage. Withdrawals do not cause this to decrease.

counted_quantity int4 10 √ null

Number of seedlings that count toward this stage’s average time in stage: those that completed the stage plus those still in it. Null if time in stage can’t be calculated for the batch.

counted_seedling_days float8 17,17 √ null

Total days spent in this stage by counted seedlings, as of time_in_stage_as_of. Null if time in stage can’t be calculated for the batch.

open_seedling_days float8 17,17 √ null

Total days spent in this stage, as of time_in_stage_as_of, by seedlings that are still in it. Null if time in stage can’t be calculated for the batch.

time_in_stage_cleared bool 1 √ null

True if a manual quantity edit changed this stage, making its time in stage unknown. Null if time in stage can’t be calculated for the batch.

time_in_stage_as_of timestamptz 35,6 √ null

Effective time of the latest quantity change; seedlings still in the stage accrue time after this. Null if time in stage can’t be calculated for the batch.

finished_quantity float8 17,17 √ null

Number of seedlings that completed this stage via a stage change or, for Ready, outplanting. Excludes seedlings still in the stage, other withdrawals, and seedlings present at batch creation except in Germinating. May be fractional because departures are split proportionally between starting seedlings and ones that entered the stage later. Null if finished time in stage has not been calculated for the batch.

finished_seedling_days float8 17,17 √ null

Total days spent in this stage by seedlings that completed it. Null if finished time in stage has not been calculated for the batch.

Indexes

Constraint Name Type Sort Column(s)
batch_stage_details_pkey Primary key Asc/Asc batch_id + stage_id
batch_stage_details_stage_id_idx Performance Asc stage_id

Check Constraints

Constraint Name Constraint
batch_stage_details_latest_observed_quantity_check (latest_observed_quantity >= 0)
batch_stage_details_quantity_check (quantity >= 0)

Relationships