plantings

0 rows


Description

Details about plants that were planted or reassigned as part of a delivery. There is one plantings row per species in a delivery.

Columns

Column Type Size Nulls Auto Default Children Parents Comments
id int8 19 null
delivery_id int8 19 null
deliveries.id plantings_planting_site_id_delivery_id_fkeyR

Which delivery this planting is part of.

planting_type_id int4 10 null
planting_types.id plantings_planting_type_id_fkeyR

Whether this is the plant assignment from the initial delivery or an adjustment from a reassignment.

planting_site_id int8 19 null
planting_subzones.planting_site_id plantings_planting_site_id_plot_id_fkeyR
planting_sites.id plantings_planting_site_id_fkeyC
deliveries.planting_site_id plantings_planting_site_id_delivery_id_fkeyR

Which planting site has the planting. Must be the same as the planting site ID of the delivery. This identifies the site as a whole; in addition, there may be a plot ID.

planting_subzone_id int8 19 null
planting_subzones.id plantings_planting_subzone_id_fkeyC

Which plot this planting affected, if any. Must be a plot at the planting site referenced by planting_site_id. Null if the planting site does not have plot information. For reassignments, this is the original plot if num_plants is negative, or the new plot if num_plants is positive.

species_id int8 19 null
species.id plantings_species_id_fkeyR

Which species was planted.

created_by int8 19 null
users.id plantings_created_by_fkeyR

Which user created the planting.

created_time timestamptz 35,6 null

When the planting was created. Note that plantings are never updated, so there is no modified time.

num_plants int4 10 null

Number of plants that were planted (if the number is positive) or reassigned (if the number is negative).

notes text 2147483647 null

Notes about this specific planting. In the initial version of the web app, the user can only enter per-planting notes for reassignments, not for initial deliveries.

Indexes

Constraint Name Type Sort Column(s)
plantings_pkey Primary key Asc id
plantings_delivery_id_idx Performance Asc delivery_id
plantings_delivery_id_species_id_planting_type_id_key Must be unique Asc/Asc/Asc delivery_id + species_id + planting_type_id
plantings_plot_id_idx Performance Asc planting_subzone_id
plantings_species_id_idx Performance Asc species_id

Check Constraints

Constraint Name Constraint
num_plants_sign_consistent_with_type ((((planting_type_id = ANY (ARRAY[2, 4])) AND (num_plants < 0)) OR ((planting_type_id <> ALL (ARRAY[2, 4])) AND (num_plants > 0))))
plantings_notes_check ((notes !~ similar_to_escape(' *'::text)))

Relationships