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.
17 lines
713 B
SQL
17 lines
713 B
SQL
CREATE TYPE companion_type AS ENUM ('beneficial', 'neutral', 'antagonistic');
|
|
|
|
CREATE TABLE companion_relationships (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
species_a_id UUID NOT NULL REFERENCES species(id) ON DELETE CASCADE,
|
|
species_b_id UUID NOT NULL REFERENCES species(id) ON DELETE CASCADE,
|
|
relationship companion_type NOT NULL,
|
|
mechanism TEXT,
|
|
source_url TEXT,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
UNIQUE(species_a_id, species_b_id),
|
|
CHECK (species_a_id < species_b_id)
|
|
);
|
|
|
|
CREATE INDEX idx_companion_a ON companion_relationships(species_a_id);
|
|
CREATE INDEX idx_companion_b ON companion_relationships(species_b_id);
|