mirror of
https://gitlab.com/mbugroup/lti-api.git
synced 2026-05-20 13:31:56 +00:00
23 lines
937 B
SQL
23 lines
937 B
SQL
CREATE TABLE IF NOT EXISTS farm_depreciation_snapshots (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
project_flock_id BIGINT NOT NULL
|
|
REFERENCES project_flocks(id)
|
|
ON UPDATE CASCADE
|
|
ON DELETE CASCADE,
|
|
period_date DATE NOT NULL,
|
|
depreciation_percent_effective NUMERIC(15, 6) NOT NULL DEFAULT 0,
|
|
depreciation_value NUMERIC(18, 3) NOT NULL DEFAULT 0,
|
|
pullet_cost_day_n_total NUMERIC(18, 3) NOT NULL DEFAULT 0,
|
|
components JSONB NOT NULL DEFAULT '{}'::jsonb,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
CONSTRAINT farm_depreciation_snapshots_unique UNIQUE (project_flock_id, period_date)
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_farm_depreciation_snapshots_period_date
|
|
ON farm_depreciation_snapshots (period_date);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_farm_depreciation_snapshots_project_flock_id
|
|
ON farm_depreciation_snapshots (project_flock_id);
|
|
|