-- Internal location operating profile for operational intelligence and AI context.
create table if not exists location_operating_profiles (
location_id uuid primary key references locations(id) on delete cascade,
organization_id uuid not null references organizations(id) on delete cascade,
concept_code text not null default 'restaurant',
service_style_code text not null default 'table_service',
production_model_code text not null default 'cook_to_order',
seat_capacity integer,
takeaway_share_percent numeric(5,2),
created_at timestamptz not null default now(),
updated_at timestamptz not null default now(),
version bigint not null default 1,
constraint location_operating_profiles_seat_capacity_check
check(seat_capacity is null or seat_capacity >= 0),
constraint location_operating_profiles_takeaway_share_check
check(
takeaway_share_percent is null
or (
takeaway_share_percent >= 0
and takeaway_share_percent <= 100
)
),
constraint location_operating_profiles_concept_check
check(
concept_code in (
'restaurant',
'italian_restaurant',
'asian_restaurant',
'chinese_restaurant',
'cafe',
'bar',
'quick_service',
'snack_bar',
'hotel_restaurant',
'fine_dining',
'catering',
'bakery_cafe',
'other'
)
),
constraint location_operating_profiles_service_style_check
check(
service_style_code in (
'table_service',
'counter_service',
'self_service',
'delivery',
'takeaway',
'mixed'
)
),
constraint location_operating_profiles_production_model_check
check(
production_model_code in (
'cook_to_order',
'batch_prep',
'central_production',
'assembly',
'hybrid'
)
)
);
create index if not exists idx_location_operating_profiles_org
on location_operating_profiles(organization_id);
