15 lines
924 B
SQL
15 lines
924 B
SQL
-- Richtpreise (Konzept, „Drei Preisquellen“): eine mitgelieferte Liste, damit
|
|
-- Kosten ab Tag 1 geschätzt werden. Global wie die Zutaten, eingespielt aus
|
|
-- db/seed/prices.de.json; eigene Preise und Bonpreise (price_points) gehen vor.
|
|
create table default_prices (
|
|
ingredient_id uuid not null references ingredients (id) on delete cascade,
|
|
currency text not null check (currency ~ '^[A-Z]{3}$'),
|
|
price_per_unit numeric(12, 6) not null check (price_per_unit >= 0), -- je g, ml oder Stück
|
|
unit text not null check (unit in ('g', 'ml', 'piece')),
|
|
primary key (ingredient_id, currency)
|
|
);
|
|
alter table default_prices enable row level security;
|
|
alter table default_prices force row level security;
|
|
create policy default_prices_read on default_prices for select using (true);
|
|
create policy default_prices_maintain on default_prices using (app_maintenance()) with check (app_maintenance());
|