<?xml version="1.0" encoding="UTF-8"?><database name="terraware_045577cc_2c057118f580" schema="seedbank" type="PostgreSQL - 17.11 (Debian 17.11-1.pgdg13+2)">
   <tables>
      <table name="accession_collectors" remarks="Names of people who collected each accession." schema="seedbank" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="accession_id" nullable="false" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="accession_collectors_accession_id_fkey" implied="false" onDeleteCascade="true" schema="seedbank" table="accessions"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="position" nullable="false" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="name" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="organization_id" nullable="false" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="accession_collectors_organization_id_fkey" implied="false" onDeleteCascade="true" schema="public" table="organizations"/>
         </column>
         <primaryKey column="accession_id" sequenceNumberInPK="1"/>
         <primaryKey column="position" sequenceNumberInPK="2"/>
         <index name="accession_collectors_pkey" unique="true">
            <column ascending="true" name="accession_id"/>
            <column ascending="true" name="position"/>
         </index>
         <index name="accession_collectors_organization_id_name_idx" unique="false">
            <column ascending="true" name="organization_id"/>
            <column ascending="true" name="name"/>
         </index>
         <checkConstraint constraint="(&quot;position&quot; &gt;= 0)" name="accession_collectors_position_check"/>
         <checkConstraint constraint="(length(name) &gt; 0)" name="name_not_empty"/>
         <checkConstraint constraint="((name !~ ('\s\s'::text COLLATE &quot;en-x-icu&quot;)) AND (name !~ ('^\s'::text COLLATE &quot;en-x-icu&quot;)) AND (name !~ ('\s$'::text COLLATE &quot;en-x-icu&quot;)))" name="name_whitespace"/>
      </table>
      <table name="accession_photos" remarks="Linking table between `accessions` and `files`." schema="seedbank" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="accession_id" nullable="false" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="accession_photo_accession_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="accessions"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="file_id" nullable="false" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="accession_photos_photo_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="files"/>
         </column>
         <primaryKey column="file_id" sequenceNumberInPK="1"/>
         <index name="accession_photos_pk" unique="true">
            <column ascending="true" name="file_id"/>
         </index>
      </table>
      <table name="accession_quantity_history" remarks="Historical record of changes to remaining quantities of accessions." schema="seedbank" type="TABLE">
         <column autoUpdated="true" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="" size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="accession_id" nullable="false" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="accession_quantity_history_accession_id_fkey" implied="false" onDeleteCascade="true" schema="seedbank" table="accessions"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="history_type_id" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="accession_quantity_history_history_type_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="accession_quantity_history_types"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="created_by" nullable="false" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="accession_quantity_history_created_by_fkey" implied="false" onDeleteCascade="false" schema="public" table="users"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="6" id="4" name="created_time" nullable="false" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="remaining_quantity" nullable="false" remarks="" size="0" type="numeric" typeCode="2"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="remaining_units_id" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="accession_quantity_history_remaining_units_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="seed_quantity_units"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="notes" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="accession_quantity_history_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <index name="accession_quantity_history_accession_id_idx" unique="false">
            <column ascending="true" name="accession_id"/>
         </index>
      </table>
      <table name="accession_quantity_history_types" remarks="(Enum) Types of operations that can result in changes to remaining quantities of accessions." schema="seedbank" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <child column="history_type_id" foreignKey="accession_quantity_history_history_type_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="accession_quantity_history"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="accession_quantity_history_types_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
      </table>
      <table name="accession_state_history" remarks="Historical record of when accessions moved to different states. A row is inserted here for every state transition." schema="seedbank" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="accession_id" nullable="false" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="accession_state_history_accession_id_fkey" implied="false" onDeleteCascade="true" schema="seedbank" table="accessions"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="6" id="1" name="updated_time" nullable="false" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="old_state_id" nullable="true" remarks="Null if this is the initial state for a new accession." size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="accession_state_history_old_state_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="accession_states"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="new_state_id" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="accession_state_history_new_state_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="accession_states"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="reason" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="updated_by" nullable="false" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="accession_state_history_updated_by_fkey" implied="false" onDeleteCascade="false" schema="public" table="users"/>
         </column>
         <index name="accession_state_history_accession_id_idx" unique="false">
            <column ascending="true" name="accession_id"/>
         </index>
         <index name="accession_state_history_new_state_id_updated_time_idx" unique="false">
            <column ascending="true" name="new_state_id"/>
            <column ascending="true" name="updated_time"/>
         </index>
      </table>
      <table name="accession_states" remarks="(Enum) Available states an accession can be in. Each state represents a step in the seed management workflow." schema="seedbank" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <child column="new_state_id" foreignKey="accession_state_history_new_state_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="accession_state_history"/>
            <child column="old_state_id" foreignKey="accession_state_history_old_state_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="accession_state_history"/>
            <child column="state_id" foreignKey="accession_state_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="accessions"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="true" digits="0" id="2" name="active" nullable="false" remarks="" size="1" type="bool" typeCode="-7"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="accession_state_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
      </table>
      <table name="accessions" remarks="Information about batches of seeds. An accession is a batch of seeds of the same species collected in the same time and place by the same people." schema="seedbank" type="TABLE">
         <column autoUpdated="true" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="" size="19" type="int8" typeCode="-5">
            <child column="accession_id" foreignKey="batch_quantity_history_accession_id_fkey" implied="false" onDeleteCascade="false" schema="nursery" table="batch_quantity_history"/>
            <child column="accession_id" foreignKey="batches_accession_id_fkey" implied="false" onDeleteCascade="false" schema="nursery" table="batches"/>
            <child column="accession_id" foreignKey="accession_collectors_accession_id_fkey" implied="false" onDeleteCascade="true" schema="seedbank" table="accession_collectors"/>
            <child column="accession_id" foreignKey="accession_photo_accession_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="accession_photos"/>
            <child column="accession_id" foreignKey="accession_quantity_history_accession_id_fkey" implied="false" onDeleteCascade="true" schema="seedbank" table="accession_quantity_history"/>
            <child column="accession_id" foreignKey="accession_state_history_accession_id_fkey" implied="false" onDeleteCascade="true" schema="seedbank" table="accession_state_history"/>
            <child column="accession_id" foreignKey="bags_accession_id_fkey" implied="false" onDeleteCascade="true" schema="seedbank" table="bags"/>
            <child column="accession_id" foreignKey="geolocations_accession_id_fkey" implied="false" onDeleteCascade="true" schema="seedbank" table="geolocations"/>
            <child column="accession_id" foreignKey="viability_tests_accession_id_fkey" implied="false" onDeleteCascade="true" schema="seedbank" table="viability_tests"/>
            <child column="accession_id" foreignKey="withdrawals_accession_id_fkey" implied="false" onDeleteCascade="true" schema="seedbank" table="withdrawals"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="facility_id" nullable="false" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="accessions_facility_id_fkey" implied="false" onDeleteCascade="true" schema="public" table="facilities"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="number" nullable="true" remarks="Displayed as the accession number to the user." size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="collected_date" nullable="true" remarks="" size="13" type="date" typeCode="91"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="received_date" nullable="true" remarks="" size="13" type="date" typeCode="91"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="state_id" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="accession_state_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="accession_states"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="founder_id" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="trees_collected_from" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="subset_weight" nullable="true" remarks="" size="0" type="numeric" typeCode="2"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="subset_count" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="10" name="est_seed_count" nullable="true" remarks="" size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="11" name="drying_end_date" nullable="true" remarks="" size="13" type="date" typeCode="91"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="12" name="processing_notes" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="13" name="sub_location_id" nullable="true" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="accession_storage_location_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="sub_locations"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="6" id="14" name="created_time" nullable="false" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="15" name="collection_site_name" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="16" name="collection_site_landowner" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="17" name="total_viability_percent" nullable="true" remarks="Percentage of viable seeds across all tests." size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="18" name="remaining_grams" nullable="true" remarks="" size="0" type="numeric" typeCode="2"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="19" name="remaining_quantity" nullable="true" remarks="" size="0" type="numeric" typeCode="2"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="20" name="remaining_units_id" nullable="true" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="accession_remaining_units_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="seed_quantity_units"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="21" name="subset_weight_grams" nullable="true" remarks="" size="0" type="numeric" typeCode="2"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="22" name="subset_weight_quantity" nullable="true" remarks="" size="0" type="numeric" typeCode="2"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="23" name="subset_weight_units_id" nullable="true" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="accession_subset_weight_units_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="seed_quantity_units"/>
         </column>
         <column autoUpdated="false" defaultValue="now()" digits="6" id="24" name="modified_time" nullable="false" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="25" name="created_by" nullable="false" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="accessions_created_by_fkey" implied="false" onDeleteCascade="false" schema="public" table="users"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="26" name="modified_by" nullable="false" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="accessions_modified_by_fkey" implied="false" onDeleteCascade="false" schema="public" table="users"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="27" name="species_id" nullable="true" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="accessions_species_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="species"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="28" name="collection_site_city" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="29" name="collection_site_country_code" nullable="true" remarks="" size="2147483647" type="text" typeCode="12">
            <parent column="code" foreignKey="accessions_collection_site_country_code_fkey" implied="false" onDeleteCascade="false" schema="public" table="countries"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="30" name="collection_site_country_subdivision" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="31" name="collection_site_notes" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="32" name="collection_source_id" nullable="true" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="accessions_collection_source_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="collection_sources"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="33" name="data_source_id" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="accessions_data_source_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="data_sources"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="34" name="latest_observed_quantity" nullable="true" remarks="Most recent remaining quantity as observed by the user." size="0" type="numeric" typeCode="2"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="35" name="latest_observed_units_id" nullable="true" remarks="Measurement units of `observed_quantity`." size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="accessions_latest_observed_units_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="seed_quantity_units"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="6" id="36" name="latest_observed_time" nullable="true" remarks="Time of most recent change to observed quantity." size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="37" name="est_weight_grams" nullable="true" remarks="" size="0" type="numeric" typeCode="2"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="38" name="est_weight_quantity" nullable="true" remarks="" size="0" type="numeric" typeCode="2"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="39" name="est_weight_units_id" nullable="true" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="accessions_est_weight_units_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="seed_quantity_units"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="40" name="total_withdrawn_count" nullable="true" remarks="Total number of seeds withdrawn. May be an estimate if withdrawals were measured by weight." size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="41" name="total_withdrawn_weight_grams" nullable="true" remarks="" size="0" type="numeric" typeCode="2"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="42" name="total_withdrawn_weight_quantity" nullable="true" remarks="Total weight of seeds withdrawn. May be an estimate if withdrawals were measured by seed count." size="0" type="numeric" typeCode="2"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="43" name="total_withdrawn_weight_units_id" nullable="true" remarks="Measurement units of `total_withdrawn_weight_quantity`." size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="accessions_total_withdrawn_weight_units_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="seed_quantity_units"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="44" name="project_id" nullable="true" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="accessions_project_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="projects"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="6" id="45" name="collected_time" nullable="true" remarks="Date and time the seeds were collected, stored at midnight UTC when only a date is known." size="35" type="timestamptz" typeCode="93"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="accession_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <index name="accession__number_trgm" unique="false">
            <column ascending="true" name="number"/>
         </index>
         <index name="accession__received_date_ix" unique="false">
            <column ascending="true" name="received_date"/>
         </index>
         <index name="accession_created_time_idx" unique="false">
            <column ascending="true" name="created_time"/>
         </index>
         <index name="accession_number_facility_unique" unique="true">
            <column ascending="true" name="number"/>
            <column ascending="true" name="facility_id"/>
         </index>
         <index name="accessions__facility_id_ix" unique="false">
            <column ascending="true" name="facility_id"/>
         </index>
         <index name="accessions__species_id_ix" unique="false">
            <column ascending="true" name="species_id"/>
         </index>
         <index name="accessions_facility_id_collection_site_name_idx" unique="false">
            <column ascending="true" name="facility_id"/>
            <column ascending="true" name="collection_site_name"/>
         </index>
         <index name="accessions_project_id_idx" unique="false">
            <column ascending="true" name="project_id"/>
         </index>
         <checkConstraint constraint="(collection_site_city !~ similar_to_escape(' *'::text))" name="accessions_collection_site_city_check"/>
         <checkConstraint constraint="(collection_site_country_code !~ similar_to_escape(' *'::text))" name="accessions_collection_site_country_code_check"/>
         <checkConstraint constraint="(collection_site_country_subdivision !~ similar_to_escape(' *'::text))" name="accessions_collection_site_country_subdivision_check"/>
         <checkConstraint constraint="(collection_site_landowner !~ similar_to_escape(' *'::text))" name="accessions_collection_site_landowner_check"/>
         <checkConstraint constraint="(collection_site_notes !~ similar_to_escape(' *'::text))" name="accessions_collection_site_notes_check"/>
         <checkConstraint constraint="(founder_id !~ similar_to_escape(' *'::text))" name="accessions_founder_id_check"/>
         <checkConstraint constraint="(number !~ similar_to_escape(' *'::text))" name="accessions_number_check"/>
         <checkConstraint constraint="(processing_notes !~ similar_to_escape(' *'::text))" name="accessions_processing_notes_check"/>
         <checkConstraint constraint="(length(collection_site_name) &gt; 0)" name="collection_site_name_nonempty"/>
         <checkConstraint constraint="(((latest_observed_quantity IS NOT NULL) AND (latest_observed_time IS NOT NULL)) OR ((latest_observed_quantity IS NULL) AND (latest_observed_time IS NULL)))" name="observed_quantity_must_have_time"/>
         <checkConstraint constraint="(((latest_observed_quantity IS NOT NULL) AND (latest_observed_units_id IS NOT NULL)) OR ((latest_observed_quantity IS NULL) AND (latest_observed_units_id IS NULL)))" name="observed_quantity_must_have_units"/>
         <checkConstraint constraint="(((remaining_quantity IS NOT NULL) AND (remaining_units_id IS NOT NULL)) OR ((remaining_quantity IS NULL) AND (remaining_units_id IS NULL)))" name="remaining_quantity_must_have_units"/>
         <checkConstraint constraint="((collection_site_name !~ ('\s\s'::text COLLATE &quot;en-x-icu&quot;)) AND (collection_site_name !~ ('^\s'::text COLLATE &quot;en-x-icu&quot;)) AND (collection_site_name !~ ('\s$'::text COLLATE &quot;en-x-icu&quot;)))" name="site_name_whitespace"/>
         <checkConstraint constraint="(((subset_weight_quantity IS NOT NULL) AND (subset_weight_units_id IS NOT NULL)) OR ((subset_weight_quantity IS NULL) AND (subset_weight_units_id IS NULL)))" name="subset_weight_quantity_must_have_units"/>
         <checkConstraint constraint="((subset_weight_units_id &lt;&gt; 1) OR (subset_weight_units_id IS NULL))" name="subset_weight_units_must_not_be_seeds"/>
      </table>
      <table name="bags" remarks="Individual bags of seeds that are part of an accession. An accession can consist of multiple bags." schema="seedbank" type="TABLE">
         <column autoUpdated="true" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="" size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="accession_id" nullable="false" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="bags_accession_id_fkey" implied="false" onDeleteCascade="true" schema="seedbank" table="accessions"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="bag_number" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="bag_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <checkConstraint constraint="(bag_number !~ similar_to_escape(' *'::text))" name="bags_bag_number_check"/>
      </table>
      <table name="collection_sources" remarks="(Enum) Types of source plants that seeds can be collected from." schema="seedbank" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <child column="collection_source_id" foreignKey="accessions_collection_source_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="accessions"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="collection_sources_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
      </table>
      <table name="data_sources" remarks="(Enum) Original sources of data, e.g., manual entry via web app." schema="seedbank" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <child column="data_source_id" foreignKey="accessions_data_source_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="accessions"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="data_sources_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
      </table>
      <table name="geolocations" remarks="Locations where seeds were collected." schema="seedbank" type="TABLE">
         <column autoUpdated="true" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="" size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="accession_id" nullable="false" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="geolocations_accession_id_fkey" implied="false" onDeleteCascade="true" schema="seedbank" table="accessions"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="6" id="2" name="created_time" nullable="true" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="7" id="3" name="latitude" nullable="false" remarks="" size="10" type="numeric" typeCode="2"/>
         <column autoUpdated="false" defaultValue="null" digits="7" id="4" name="longitude" nullable="false" remarks="" size="10" type="numeric" typeCode="2"/>
         <column autoUpdated="false" defaultValue="null" digits="17" id="5" name="gps_accuracy" nullable="true" remarks="" size="17" type="float8" typeCode="8"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="collection_event_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <index name="geolocation__accession_id_ix" unique="false">
            <column ascending="true" name="accession_id"/>
         </index>
      </table>
      <table name="seed_quantity_units" remarks="(Enum) Available units in which seeds can be measured. For weight-based units, includes unit conversion information." schema="seedbank" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <child column="remaining_units_id" foreignKey="accession_quantity_history_remaining_units_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="accession_quantity_history"/>
            <child column="est_weight_units_id" foreignKey="accessions_est_weight_units_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="accessions"/>
            <child column="latest_observed_units_id" foreignKey="accessions_latest_observed_units_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="accessions"/>
            <child column="remaining_units_id" foreignKey="accession_remaining_units_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="accessions"/>
            <child column="subset_weight_units_id" foreignKey="accession_subset_weight_units_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="accessions"/>
            <child column="total_withdrawn_weight_units_id" foreignKey="accessions_total_withdrawn_weight_units_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="accessions"/>
            <child column="estimated_weight_units_id" foreignKey="withdrawals_estimated_weight_units_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="withdrawals"/>
            <child column="withdrawn_units_id" foreignKey="withdrawal_withdrawn_units_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="withdrawals"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="seed_quantity_units_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
      </table>
      <table name="viability_test_results" remarks="Result from a viability test of a batch of seeds. Viability tests can have multiple germinations, e.g., if different seeds germinate on different days." schema="seedbank" type="TABLE">
         <column autoUpdated="true" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="" size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="test_id" nullable="false" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="viability_test_results_test_id_fkey" implied="false" onDeleteCascade="true" schema="seedbank" table="viability_tests"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="recording_date" nullable="false" remarks="" size="13" type="date" typeCode="91"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="seeds_germinated" nullable="false" remarks="" size="10" type="int4" typeCode="4"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="viability_test_results_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <index name="viability_test_results__test_id_ix" unique="false">
            <column ascending="true" name="test_id"/>
         </index>
      </table>
      <table name="viability_test_seed_types" remarks="(Enum) Types of seeds that can be tested for viability. This refers to how the seeds were stored, not the physical characteristics of the seeds themselves." schema="seedbank" type="TABLE">
         <column autoUpdated="true" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <child column="seed_type_id" foreignKey="germination_test_seed_type_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="viability_tests"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="germination_seed_type_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
      </table>
      <table name="viability_test_substrates" remarks="(Enum) Types of substrate that can be used to test seeds for viability." schema="seedbank" type="TABLE">
         <column autoUpdated="true" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <child column="substrate_id" foreignKey="germination_test_substrate_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="viability_tests"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="germination_substrate_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
      </table>
      <table name="viability_test_types" remarks="(Enum) Types of tests that can be performed on seeds to check for viability." schema="seedbank" type="TABLE">
         <column autoUpdated="false" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <child column="test_type" foreignKey="germination_test_test_type_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="viability_tests"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="germination_test_type_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <index name="germination_test_type_name_key" unique="true">
            <column ascending="true" name="name"/>
         </index>
      </table>
      <table name="viability_tests" remarks="Information about a single batch of seeds being tested for viability. This is the information about the test itself; the results are represented in the `viability_test_results` table." schema="seedbank" type="TABLE">
         <column autoUpdated="true" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="" size="19" type="int8" typeCode="-5">
            <child column="test_id" foreignKey="viability_test_results_test_id_fkey" implied="false" onDeleteCascade="true" schema="seedbank" table="viability_test_results"/>
            <child column="viability_test_id" foreignKey="withdrawals_viability_test_id_fkey" implied="false" onDeleteCascade="true" schema="seedbank" table="withdrawals"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="accession_id" nullable="false" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="viability_tests_accession_id_fkey" implied="false" onDeleteCascade="true" schema="seedbank" table="accessions"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="test_type" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="germination_test_test_type_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="viability_test_types"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="start_date" nullable="true" remarks="" size="13" type="date" typeCode="91"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="seed_type_id" nullable="true" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="germination_test_seed_type_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="viability_test_seed_types"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="substrate_id" nullable="true" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="germination_test_substrate_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="viability_test_substrates"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="6" name="treatment_id" nullable="true" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="germination_test_treatment_id_fkey" implied="false" onDeleteCascade="false" schema="public" table="seed_treatments"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="7" name="seeds_sown" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="notes" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="staff_responsible" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="10" name="total_seeds_germinated" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="11" name="total_percent_germinated" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="12" name="end_date" nullable="true" remarks="" size="13" type="date" typeCode="91"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="13" name="seeds_compromised" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="14" name="seeds_empty" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="15" name="seeds_filled" nullable="true" remarks="" size="10" type="int4" typeCode="4"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="16" name="substrate_notes" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="viability_tests_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <index name="viability_test__accession_id_ix" unique="false">
            <column ascending="true" name="accession_id"/>
         </index>
         <checkConstraint constraint="(notes !~ similar_to_escape(' *'::text))" name="viability_tests_notes_check"/>
         <checkConstraint constraint="(staff_responsible !~ similar_to_escape(' *'::text))" name="viability_tests_staff_responsible_check"/>
      </table>
      <table name="withdrawal_purposes" remarks="(Enum) Reasons that someone can withdraw seeds from a seed bank." schema="seedbank" type="TABLE">
         <column autoUpdated="true" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="" size="10" type="int4" typeCode="4">
            <child column="purpose_id" foreignKey="withdrawal_purpose_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="withdrawals"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="name" nullable="false" remarks="" size="2147483647" type="text" typeCode="12"/>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="withdrawal_purpose_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
      </table>
      <table name="withdrawals" remarks="Information about seeds that have been withdrawn from a seed bank. Each time someone withdraws seeds, a new row is inserted here." schema="seedbank" type="TABLE">
         <column autoUpdated="true" defaultValue="null" digits="0" id="0" name="id" nullable="false" remarks="" size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="1" name="accession_id" nullable="false" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="withdrawals_accession_id_fkey" implied="false" onDeleteCascade="true" schema="seedbank" table="accessions"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="2" name="date" nullable="false" remarks="" size="13" type="date" typeCode="91"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="3" name="purpose_id" nullable="true" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="withdrawal_purpose_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="withdrawal_purposes"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="4" name="destination" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="5" name="staff_responsible" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="6" name="created_time" nullable="false" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="6" id="7" name="updated_time" nullable="false" remarks="" size="35" type="timestamptz" typeCode="93"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="8" name="notes" nullable="true" remarks="" size="2147483647" type="text" typeCode="12"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="9" name="viability_test_id" nullable="true" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="withdrawals_viability_test_id_fkey" implied="false" onDeleteCascade="true" schema="seedbank" table="viability_tests"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="10" name="withdrawn_grams" nullable="true" remarks="" size="0" type="numeric" typeCode="2"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="11" name="withdrawn_quantity" nullable="true" remarks="" size="0" type="numeric" typeCode="2"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="12" name="withdrawn_units_id" nullable="true" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="withdrawal_withdrawn_units_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="seed_quantity_units"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="13" name="estimated_count" nullable="true" remarks="" size="19" type="int8" typeCode="-5"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="14" name="estimated_weight_quantity" nullable="true" remarks="" size="0" type="numeric" typeCode="2"/>
         <column autoUpdated="false" defaultValue="null" digits="0" id="15" name="estimated_weight_units_id" nullable="true" remarks="" size="10" type="int4" typeCode="4">
            <parent column="id" foreignKey="withdrawals_estimated_weight_units_id_fkey" implied="false" onDeleteCascade="false" schema="seedbank" table="seed_quantity_units"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="16" name="created_by" nullable="true" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="withdrawals_created_by_fkey" implied="false" onDeleteCascade="false" schema="public" table="users"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="17" name="withdrawn_by" nullable="true" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="withdrawals_withdrawn_by_fkey" implied="false" onDeleteCascade="false" schema="public" table="users"/>
         </column>
         <column autoUpdated="false" defaultValue="null" digits="0" id="18" name="batch_id" nullable="true" remarks="" size="19" type="int8" typeCode="-5">
            <parent column="id" foreignKey="withdrawals_batch_id_fkey" implied="false" onDeleteCascade="false" schema="nursery" table="batches"/>
         </column>
         <primaryKey column="id" sequenceNumberInPK="1"/>
         <index name="withdrawal_pkey" unique="true">
            <column ascending="true" name="id"/>
         </index>
         <index name="withdrawal__accession_id_ix" unique="false">
            <column ascending="true" name="accession_id"/>
         </index>
         <index name="withdrawal__date_ix" unique="false">
            <column ascending="true" name="date"/>
         </index>
         <index name="withdrawals_batch_id_idx" unique="false">
            <column ascending="true" name="batch_id"/>
         </index>
         <index name="withdrawals_viability_test_id_unique" unique="true">
            <column ascending="true" name="viability_test_id"/>
         </index>
         <checkConstraint constraint="(((estimated_weight_quantity IS NOT NULL) AND (estimated_weight_units_id IS NOT NULL)) OR ((estimated_weight_quantity IS NULL) AND (estimated_weight_units_id IS NULL)))" name="estimated_weight_must_have_units"/>
         <checkConstraint constraint="(destination !~ similar_to_escape(' *'::text))" name="withdrawals_destination_check"/>
         <checkConstraint constraint="(notes !~ similar_to_escape(' *'::text))" name="withdrawals_notes_check"/>
         <checkConstraint constraint="(staff_responsible !~ similar_to_escape(' *'::text))" name="withdrawals_staff_responsible_check"/>
         <checkConstraint constraint="(((viability_test_id IS NULL) AND ((purpose_id IS NULL) OR (purpose_id &lt;&gt; 7))) OR ((viability_test_id IS NOT NULL) AND (purpose_id IS NOT NULL) AND (purpose_id = 7)))" name="withdrawals_test_id_requires_purpose"/>
         <checkConstraint constraint="(((purpose_id &lt;&gt; 7) AND (viability_test_id IS NULL)) OR ((purpose_id = 7) AND (viability_test_id IS NOT NULL)))" name="withdrawals_viability_testing_has_test_id"/>
      </table>
   </tables>
</database>
