484979ad53
Rust/Axum REST API (herbapi-api) with PostgreSQL, S3/Garage, OIDC auth. Dioxus 0.7 WASM frontend (herbapi-ui) with sidebar layout and botanical reference style. 9 SQL migrations covering families, species, cultivars, suppliers, companions, images, users, API tokens.
79 lines
3.0 KiB
SQL
79 lines
3.0 KiB
SQL
CREATE TYPE frost_tolerance AS ENUM ('none', 'light_frost', 'moderate_frost', 'hardy');
|
|
|
|
CREATE TABLE cultivars (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
slug TEXT NOT NULL UNIQUE,
|
|
species_id UUID NOT NULL REFERENCES species(id) ON DELETE RESTRICT,
|
|
name TEXT NOT NULL,
|
|
name_en TEXT,
|
|
name_de TEXT,
|
|
name_scientific TEXT,
|
|
description TEXT,
|
|
is_organic BOOLEAN NOT NULL DEFAULT FALSE,
|
|
perennial BOOLEAN NOT NULL DEFAULT FALSE,
|
|
growing_time_days INTEGER,
|
|
planting_depth_cm NUMERIC(5,2),
|
|
row_spacing_cm NUMERIC(5,2),
|
|
plant_spacing_cm NUMERIC(5,2),
|
|
days_to_germination INTEGER,
|
|
germination_temp_c NUMERIC(5,2),
|
|
light_requirement TEXT,
|
|
stratification_required BOOLEAN,
|
|
stratification_days INTEGER,
|
|
scarification_required BOOLEAN,
|
|
seed_viability_years INTEGER,
|
|
storage_temp_c NUMERIC(5,2),
|
|
storage_humidity TEXT,
|
|
storage_notes TEXT,
|
|
min_temp NUMERIC(5,2),
|
|
max_temp NUMERIC(5,2),
|
|
humidity TEXT,
|
|
light TEXT,
|
|
frost_tolerance frost_tolerance,
|
|
min_light_hours_day NUMERIC(4,1),
|
|
optimal_light_hours_day NUMERIC(4,1),
|
|
greenhouse_min_temp_c NUMERIC(5,2),
|
|
indoor_season_extension_weeks INTEGER,
|
|
ventilation_requirement TEXT,
|
|
heating_required BOOLEAN,
|
|
indoor_sowing_months INTEGER[],
|
|
direct_sowing_months INTEGER[],
|
|
transplanting_months INTEGER[],
|
|
glasshouse_months INTEGER[],
|
|
harvesting_months INTEGER[],
|
|
succession_planting_days INTEGER,
|
|
planting_notes TEXT,
|
|
propagation_methods TEXT[],
|
|
cutting_season TEXT,
|
|
rootstock_species_id UUID REFERENCES species(id),
|
|
years_to_first_harvest INTEGER,
|
|
productive_lifespan_years INTEGER,
|
|
expected_yield_kg_per_m2 NUMERIC(8,2),
|
|
yield_unit TEXT,
|
|
expected_yield_value NUMERIC(8,2),
|
|
harvest_window_days INTEGER,
|
|
storage_method TEXT[],
|
|
shelf_life_days INTEGER,
|
|
cold_storage_days INTEGER,
|
|
pollination_group TEXT,
|
|
self_fertile BOOLEAN,
|
|
rootstock_compatibility TEXT,
|
|
wikidata_qid TEXT,
|
|
gbif_id TEXT,
|
|
pfaf_url TEXT,
|
|
primary_image_key TEXT,
|
|
source_urls TEXT[],
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
|
);
|
|
|
|
CREATE INDEX idx_cultivars_species ON cultivars(species_id);
|
|
CREATE INDEX idx_cultivars_rootstock ON cultivars(rootstock_species_id) WHERE rootstock_species_id IS NOT NULL;
|
|
CREATE INDEX idx_cultivars_search ON cultivars
|
|
USING GIN (to_tsvector('english',
|
|
coalesce(name,'') || ' ' ||
|
|
coalesce(name_en,'') || ' ' ||
|
|
coalesce(name_de,'') || ' ' ||
|
|
coalesce(name_scientific,'') || ' ' ||
|
|
coalesce(description,'')));
|