@fayz-ai/plugin-menu 0.10.2 → 0.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{MenuPage-2LLWRJGN.js → MenuPage-ZFBHFDZI.js} +39 -34
- package/dist/MenuPage-ZFBHFDZI.js.map +1 -0
- package/dist/components/DraftSectionCard.d.ts +2 -1
- package/dist/components/DraftSectionCard.d.ts.map +1 -1
- package/dist/data/legacy-adapter.d.ts +14 -0
- package/dist/data/legacy-adapter.d.ts.map +1 -1
- package/dist/data/platform.d.ts.map +1 -1
- package/dist/index.js +598 -369
- package/dist/index.js.map +1 -1
- package/dist/migrations/index.d.ts +1 -4
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/types.d.ts +8 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/views/MenuManagerView.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/MenuPage-2LLWRJGN.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1007,383 +1007,578 @@ function createSupabaseMenuProvider(options) {
|
|
|
1007
1007
|
}
|
|
1008
1008
|
|
|
1009
1009
|
// src/migrations/index.ts
|
|
1010
|
-
var
|
|
1010
|
+
var MIGRATION_000_BASELINE = `-- ============================================================================
|
|
1011
|
+
-- plugins/plugin-menu/src/migrations/000_baseline.sql \u2014 what installing this provisions, as one file.
|
|
1011
1012
|
--
|
|
1012
|
-
--
|
|
1013
|
-
--
|
|
1014
|
-
--
|
|
1015
|
-
--
|
|
1016
|
-
--
|
|
1017
|
-
--
|
|
1018
|
-
--
|
|
1019
|
-
--
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1013
|
+
-- GENERATED by scripts/emit-unit-baselines.mjs (#338). Do not edit by hand:
|
|
1014
|
+
-- change the schema, regenerate, and let scripts/check-chain-equivalence.mjs
|
|
1015
|
+
-- prove the result still matches.
|
|
1016
|
+
--
|
|
1017
|
+
-- This replaced 4 migration files. They are kept, unapplied, in
|
|
1018
|
+
-- migrations.archive/ \u2014 a year of decisions is worth reading even when it is no
|
|
1019
|
+
-- longer worth replaying.
|
|
1020
|
+
--
|
|
1021
|
+
-- Object order is fixed rather than dependency-sorted: schemas, types,
|
|
1022
|
+
-- sequences, tables, defaults, functions, constraints, views, indexes, foreign
|
|
1023
|
+
-- keys, triggers, row security, policies, grants. Dependencies BETWEEN units
|
|
1024
|
+
-- are carried by the order packages/db/chain.json declares.
|
|
1025
|
+
-- ============================================================================
|
|
1026
|
+
|
|
1027
|
+
-- A LANGUAGE sql function binds its body at CREATE time, and 570 functions
|
|
1028
|
+
-- sorted by name are not sorted by who calls whom. This is what lets them load
|
|
1029
|
+
-- in any order; every body is still compiled on first call, so a genuinely
|
|
1030
|
+
-- broken reference surfaces then rather than never. Session-scoped.
|
|
1031
|
+
SET check_function_bodies = false;
|
|
1032
|
+
|
|
1033
|
+
|
|
1034
|
+
|
|
1035
|
+
-- \u2500\u2500 default privileges: reset \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
1036
|
+
-- Cleared BEFORE anything is created, so every object below gets the ACL the
|
|
1037
|
+
-- dump describes rather than the image's defaults on top of it. Restored at
|
|
1038
|
+
-- the end of this file.
|
|
1039
|
+
|
|
1040
|
+
DO $dp$ BEGIN
|
|
1041
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public REVOKE ALL ON SEQUENCES FROM anon, authenticated, service_role, fayz_connector$stmt$;
|
|
1042
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1043
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public REVOKE ALL ON SEQUENCES FROM anon, authenticated, service_role, fayz_connector$stmt$;
|
|
1044
|
+
END $dp$;
|
|
1045
|
+
|
|
1046
|
+
DO $dp$ BEGIN
|
|
1047
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public REVOKE ALL ON SEQUENCES FROM anon, authenticated, service_role, fayz_connector$stmt$;
|
|
1048
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1049
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public REVOKE ALL ON SEQUENCES FROM anon, authenticated, service_role, fayz_connector$stmt$;
|
|
1050
|
+
END $dp$;
|
|
1051
|
+
|
|
1052
|
+
DO $dp$ BEGIN
|
|
1053
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public REVOKE ALL ON FUNCTIONS FROM anon, authenticated, service_role, fayz_connector$stmt$;
|
|
1054
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1055
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public REVOKE ALL ON FUNCTIONS FROM anon, authenticated, service_role, fayz_connector$stmt$;
|
|
1056
|
+
END $dp$;
|
|
1057
|
+
|
|
1058
|
+
DO $dp$ BEGIN
|
|
1059
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public REVOKE ALL ON FUNCTIONS FROM anon, authenticated, service_role, fayz_connector$stmt$;
|
|
1060
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1061
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public REVOKE ALL ON FUNCTIONS FROM anon, authenticated, service_role, fayz_connector$stmt$;
|
|
1062
|
+
END $dp$;
|
|
1063
|
+
|
|
1064
|
+
DO $dp$ BEGIN
|
|
1065
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public REVOKE ALL ON TABLES FROM anon, authenticated, service_role, fayz_connector$stmt$;
|
|
1066
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1067
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public REVOKE ALL ON TABLES FROM anon, authenticated, service_role, fayz_connector$stmt$;
|
|
1068
|
+
END $dp$;
|
|
1069
|
+
|
|
1070
|
+
DO $dp$ BEGIN
|
|
1071
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public REVOKE ALL ON TABLES FROM anon, authenticated, service_role, fayz_connector$stmt$;
|
|
1072
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1073
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public REVOKE ALL ON TABLES FROM anon, authenticated, service_role, fayz_connector$stmt$;
|
|
1074
|
+
END $dp$;
|
|
1075
|
+
|
|
1076
|
+
|
|
1077
|
+
-- \u2500\u2500 table \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
1078
|
+
|
|
1079
|
+
CREATE TABLE public.plg_menu_allergens (
|
|
1080
|
+
id uuid DEFAULT gen_random_uuid() NOT NULL,
|
|
1081
|
+
tenant_id uuid NOT NULL,
|
|
1082
|
+
name text NOT NULL,
|
|
1083
|
+
icon text,
|
|
1084
|
+
is_active boolean DEFAULT true NOT NULL,
|
|
1085
|
+
created_at timestamp with time zone DEFAULT now() NOT NULL
|
|
1035
1086
|
);
|
|
1036
|
-
|
|
1037
|
-
CREATE
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
description text,
|
|
1045
|
-
image_url text,
|
|
1046
|
-
sort_order integer NOT NULL DEFAULT 0,
|
|
1047
|
-
is_active boolean NOT NULL DEFAULT true,
|
|
1048
|
-
availability jsonb NOT NULL DEFAULT '{}'::jsonb,
|
|
1049
|
-
-- Set when the section was adopted from a legacy flat category, so the
|
|
1050
|
-
-- backfill can run twice without doubling the sections.
|
|
1051
|
-
legacy_category_id uuid,
|
|
1052
|
-
created_at timestamptz NOT NULL DEFAULT now(),
|
|
1053
|
-
updated_at timestamptz NOT NULL DEFAULT now()
|
|
1087
|
+
|
|
1088
|
+
CREATE TABLE public.plg_menu_dietary_tags (
|
|
1089
|
+
id uuid DEFAULT gen_random_uuid() NOT NULL,
|
|
1090
|
+
tenant_id uuid NOT NULL,
|
|
1091
|
+
name text NOT NULL,
|
|
1092
|
+
color text,
|
|
1093
|
+
is_active boolean DEFAULT true NOT NULL,
|
|
1094
|
+
created_at timestamp with time zone DEFAULT now() NOT NULL
|
|
1054
1095
|
);
|
|
1055
|
-
|
|
1056
|
-
CREATE
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
1063
|
-
tenant_id uuid NOT NULL REFERENCES public.tenants(id) ON DELETE CASCADE,
|
|
1064
|
-
section_id uuid NOT NULL REFERENCES public.plg_menu_sections(id) ON DELETE CASCADE,
|
|
1065
|
-
item_id uuid NOT NULL REFERENCES public.products(id) ON DELETE CASCADE,
|
|
1066
|
-
sort_order integer NOT NULL DEFAULT 0,
|
|
1067
|
-
price_override numeric(14,2),
|
|
1068
|
-
is_active boolean NOT NULL DEFAULT true,
|
|
1069
|
-
created_at timestamptz NOT NULL DEFAULT now(),
|
|
1070
|
-
updated_at timestamptz NOT NULL DEFAULT now()
|
|
1096
|
+
|
|
1097
|
+
CREATE TABLE public.plg_menu_item_modifier_groups (
|
|
1098
|
+
id uuid DEFAULT gen_random_uuid() NOT NULL,
|
|
1099
|
+
tenant_id uuid NOT NULL,
|
|
1100
|
+
product_id uuid NOT NULL,
|
|
1101
|
+
group_id uuid NOT NULL,
|
|
1102
|
+
sort_order integer DEFAULT 0 NOT NULL
|
|
1071
1103
|
);
|
|
1072
|
-
|
|
1073
|
-
CREATE
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
is_featured boolean NOT NULL DEFAULT false,
|
|
1088
|
-
sort_order integer NOT NULL DEFAULT 0,
|
|
1089
|
-
created_at timestamptz NOT NULL DEFAULT now(),
|
|
1090
|
-
updated_at timestamptz NOT NULL DEFAULT now()
|
|
1104
|
+
|
|
1105
|
+
CREATE TABLE public.plg_menu_items (
|
|
1106
|
+
product_id uuid NOT NULL,
|
|
1107
|
+
tenant_id uuid NOT NULL,
|
|
1108
|
+
status text DEFAULT 'available'::text NOT NULL,
|
|
1109
|
+
available_for_pos boolean DEFAULT true NOT NULL,
|
|
1110
|
+
available_for_delivery boolean DEFAULT true NOT NULL,
|
|
1111
|
+
delivery_price numeric(14,2),
|
|
1112
|
+
prep_time_minutes integer,
|
|
1113
|
+
allergens text[] DEFAULT ARRAY[]::text[] NOT NULL,
|
|
1114
|
+
dietary_tags text[] DEFAULT ARRAY[]::text[] NOT NULL,
|
|
1115
|
+
is_featured boolean DEFAULT false NOT NULL,
|
|
1116
|
+
sort_order integer DEFAULT 0 NOT NULL,
|
|
1117
|
+
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
1118
|
+
updated_at timestamp with time zone DEFAULT now() NOT NULL
|
|
1091
1119
|
);
|
|
1092
|
-
|
|
1093
|
-
CREATE
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
created_at timestamptz NOT NULL DEFAULT now()
|
|
1120
|
+
|
|
1121
|
+
CREATE TABLE public.plg_menu_menus (
|
|
1122
|
+
id uuid DEFAULT gen_random_uuid() NOT NULL,
|
|
1123
|
+
tenant_id uuid NOT NULL,
|
|
1124
|
+
name text NOT NULL,
|
|
1125
|
+
description text,
|
|
1126
|
+
is_active boolean DEFAULT true NOT NULL,
|
|
1127
|
+
sort_order integer DEFAULT 0 NOT NULL,
|
|
1128
|
+
channels text[] DEFAULT ARRAY['pos'::text, 'delivery'::text, 'digital'::text] NOT NULL,
|
|
1129
|
+
availability jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
1130
|
+
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
1131
|
+
updated_at timestamp with time zone DEFAULT now() NOT NULL
|
|
1105
1132
|
);
|
|
1106
|
-
|
|
1107
|
-
CREATE
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
sort_order integer NOT NULL DEFAULT 0,
|
|
1117
|
-
created_at timestamptz NOT NULL DEFAULT now()
|
|
1133
|
+
|
|
1134
|
+
CREATE TABLE public.plg_menu_modifier_groups (
|
|
1135
|
+
id uuid DEFAULT gen_random_uuid() NOT NULL,
|
|
1136
|
+
tenant_id uuid NOT NULL,
|
|
1137
|
+
name text NOT NULL,
|
|
1138
|
+
min_selections integer DEFAULT 0 NOT NULL,
|
|
1139
|
+
max_selections integer DEFAULT 1 NOT NULL,
|
|
1140
|
+
is_required boolean DEFAULT false NOT NULL,
|
|
1141
|
+
sort_order integer DEFAULT 0 NOT NULL,
|
|
1142
|
+
created_at timestamp with time zone DEFAULT now() NOT NULL
|
|
1118
1143
|
);
|
|
1119
|
-
|
|
1120
|
-
CREATE
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1144
|
+
|
|
1145
|
+
CREATE TABLE public.plg_menu_modifiers (
|
|
1146
|
+
id uuid DEFAULT gen_random_uuid() NOT NULL,
|
|
1147
|
+
tenant_id uuid NOT NULL,
|
|
1148
|
+
group_id uuid NOT NULL,
|
|
1149
|
+
name text NOT NULL,
|
|
1150
|
+
price_adjustment numeric(14,2) DEFAULT 0 NOT NULL,
|
|
1151
|
+
is_active boolean DEFAULT true NOT NULL,
|
|
1152
|
+
sort_order integer DEFAULT 0 NOT NULL,
|
|
1153
|
+
created_at timestamp with time zone DEFAULT now() NOT NULL
|
|
1128
1154
|
);
|
|
1129
|
-
|
|
1130
|
-
CREATE
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1155
|
+
|
|
1156
|
+
CREATE TABLE public.plg_menu_placements (
|
|
1157
|
+
id uuid DEFAULT gen_random_uuid() NOT NULL,
|
|
1158
|
+
tenant_id uuid NOT NULL,
|
|
1159
|
+
section_id uuid NOT NULL,
|
|
1160
|
+
item_id uuid NOT NULL,
|
|
1161
|
+
sort_order integer DEFAULT 0 NOT NULL,
|
|
1162
|
+
price_override numeric(14,2),
|
|
1163
|
+
is_active boolean DEFAULT true NOT NULL,
|
|
1164
|
+
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
1165
|
+
updated_at timestamp with time zone DEFAULT now() NOT NULL
|
|
1139
1166
|
);
|
|
1140
|
-
|
|
1141
|
-
CREATE
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1167
|
+
|
|
1168
|
+
CREATE TABLE public.plg_menu_sections (
|
|
1169
|
+
id uuid DEFAULT gen_random_uuid() NOT NULL,
|
|
1170
|
+
tenant_id uuid NOT NULL,
|
|
1171
|
+
menu_id uuid NOT NULL,
|
|
1172
|
+
name text NOT NULL,
|
|
1173
|
+
description text,
|
|
1174
|
+
image_url text,
|
|
1175
|
+
sort_order integer DEFAULT 0 NOT NULL,
|
|
1176
|
+
is_active boolean DEFAULT true NOT NULL,
|
|
1177
|
+
availability jsonb DEFAULT '{}'::jsonb NOT NULL,
|
|
1178
|
+
legacy_category_id uuid,
|
|
1179
|
+
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
1180
|
+
updated_at timestamp with time zone DEFAULT now() NOT NULL
|
|
1150
1181
|
);
|
|
1182
|
+
|
|
1183
|
+
|
|
1184
|
+
-- \u2500\u2500 constraint \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
1185
|
+
|
|
1186
|
+
ALTER TABLE ONLY public.plg_menu_allergens
|
|
1187
|
+
ADD CONSTRAINT plg_menu_allergens_pkey PRIMARY KEY (id);
|
|
1188
|
+
|
|
1189
|
+
ALTER TABLE ONLY public.plg_menu_dietary_tags
|
|
1190
|
+
ADD CONSTRAINT plg_menu_dietary_tags_pkey PRIMARY KEY (id);
|
|
1191
|
+
|
|
1192
|
+
ALTER TABLE ONLY public.plg_menu_item_modifier_groups
|
|
1193
|
+
ADD CONSTRAINT plg_menu_item_modifier_groups_pkey PRIMARY KEY (id);
|
|
1194
|
+
|
|
1195
|
+
ALTER TABLE ONLY public.plg_menu_items
|
|
1196
|
+
ADD CONSTRAINT plg_menu_items_pkey PRIMARY KEY (product_id);
|
|
1197
|
+
|
|
1198
|
+
ALTER TABLE ONLY public.plg_menu_menus
|
|
1199
|
+
ADD CONSTRAINT plg_menu_menus_pkey PRIMARY KEY (id);
|
|
1200
|
+
|
|
1201
|
+
ALTER TABLE ONLY public.plg_menu_modifier_groups
|
|
1202
|
+
ADD CONSTRAINT plg_menu_modifier_groups_pkey PRIMARY KEY (id);
|
|
1203
|
+
|
|
1204
|
+
ALTER TABLE ONLY public.plg_menu_modifiers
|
|
1205
|
+
ADD CONSTRAINT plg_menu_modifiers_pkey PRIMARY KEY (id);
|
|
1206
|
+
|
|
1207
|
+
ALTER TABLE ONLY public.plg_menu_placements
|
|
1208
|
+
ADD CONSTRAINT plg_menu_placements_pkey PRIMARY KEY (id);
|
|
1209
|
+
|
|
1210
|
+
ALTER TABLE ONLY public.plg_menu_sections
|
|
1211
|
+
ADD CONSTRAINT plg_menu_sections_pkey PRIMARY KEY (id);
|
|
1212
|
+
|
|
1213
|
+
|
|
1214
|
+
-- \u2500\u2500 index \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
1215
|
+
|
|
1216
|
+
CREATE INDEX idx_plg_menu_allergens_tenant ON public.plg_menu_allergens USING btree (tenant_id);
|
|
1217
|
+
|
|
1218
|
+
CREATE INDEX idx_plg_menu_dietary_tags_tenant ON public.plg_menu_dietary_tags USING btree (tenant_id);
|
|
1219
|
+
|
|
1220
|
+
CREATE INDEX idx_plg_menu_items_tenant ON public.plg_menu_items USING btree (tenant_id);
|
|
1221
|
+
|
|
1222
|
+
CREATE INDEX idx_plg_menu_menus_tenant ON public.plg_menu_menus USING btree (tenant_id, sort_order);
|
|
1223
|
+
|
|
1224
|
+
CREATE INDEX idx_plg_menu_modifier_groups_tenant ON public.plg_menu_modifier_groups USING btree (tenant_id);
|
|
1225
|
+
|
|
1226
|
+
CREATE INDEX idx_plg_menu_modifiers_group ON public.plg_menu_modifiers USING btree (group_id, sort_order);
|
|
1227
|
+
|
|
1228
|
+
CREATE INDEX idx_plg_menu_placements_item ON public.plg_menu_placements USING btree (item_id);
|
|
1229
|
+
|
|
1230
|
+
CREATE INDEX idx_plg_menu_placements_section ON public.plg_menu_placements USING btree (section_id, sort_order);
|
|
1231
|
+
|
|
1232
|
+
CREATE INDEX idx_plg_menu_sections_menu ON public.plg_menu_sections USING btree (menu_id, sort_order);
|
|
1233
|
+
|
|
1234
|
+
CREATE INDEX idx_plg_menu_sections_tenant ON public.plg_menu_sections USING btree (tenant_id);
|
|
1235
|
+
|
|
1236
|
+
CREATE UNIQUE INDEX uq_plg_menu_item_modifier_groups ON public.plg_menu_item_modifier_groups USING btree (product_id, group_id);
|
|
1237
|
+
|
|
1238
|
+
CREATE UNIQUE INDEX uq_plg_menu_placements_seat ON public.plg_menu_placements USING btree (section_id, item_id);
|
|
1239
|
+
|
|
1240
|
+
CREATE UNIQUE INDEX uq_plg_menu_sections_legacy ON public.plg_menu_sections USING btree (menu_id, legacy_category_id) WHERE (legacy_category_id IS NOT NULL);
|
|
1241
|
+
|
|
1242
|
+
|
|
1243
|
+
-- \u2500\u2500 fk constraint \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
1244
|
+
|
|
1245
|
+
ALTER TABLE ONLY public.plg_menu_allergens
|
|
1246
|
+
ADD CONSTRAINT plg_menu_allergens_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE;
|
|
1247
|
+
|
|
1248
|
+
ALTER TABLE ONLY public.plg_menu_dietary_tags
|
|
1249
|
+
ADD CONSTRAINT plg_menu_dietary_tags_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE;
|
|
1250
|
+
|
|
1251
|
+
ALTER TABLE ONLY public.plg_menu_item_modifier_groups
|
|
1252
|
+
ADD CONSTRAINT plg_menu_item_modifier_groups_group_id_fkey FOREIGN KEY (group_id) REFERENCES public.plg_menu_modifier_groups(id) ON DELETE CASCADE;
|
|
1253
|
+
|
|
1254
|
+
ALTER TABLE ONLY public.plg_menu_item_modifier_groups
|
|
1255
|
+
ADD CONSTRAINT plg_menu_item_modifier_groups_product_id_fkey FOREIGN KEY (product_id) REFERENCES public.products(id) ON DELETE CASCADE;
|
|
1256
|
+
|
|
1257
|
+
ALTER TABLE ONLY public.plg_menu_item_modifier_groups
|
|
1258
|
+
ADD CONSTRAINT plg_menu_item_modifier_groups_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE;
|
|
1259
|
+
|
|
1260
|
+
ALTER TABLE ONLY public.plg_menu_items
|
|
1261
|
+
ADD CONSTRAINT plg_menu_items_product_id_fkey FOREIGN KEY (product_id) REFERENCES public.products(id) ON DELETE CASCADE;
|
|
1262
|
+
|
|
1263
|
+
ALTER TABLE ONLY public.plg_menu_items
|
|
1264
|
+
ADD CONSTRAINT plg_menu_items_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE;
|
|
1265
|
+
|
|
1266
|
+
ALTER TABLE ONLY public.plg_menu_menus
|
|
1267
|
+
ADD CONSTRAINT plg_menu_menus_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE;
|
|
1268
|
+
|
|
1269
|
+
ALTER TABLE ONLY public.plg_menu_modifier_groups
|
|
1270
|
+
ADD CONSTRAINT plg_menu_modifier_groups_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE;
|
|
1271
|
+
|
|
1272
|
+
ALTER TABLE ONLY public.plg_menu_modifiers
|
|
1273
|
+
ADD CONSTRAINT plg_menu_modifiers_group_id_fkey FOREIGN KEY (group_id) REFERENCES public.plg_menu_modifier_groups(id) ON DELETE CASCADE;
|
|
1274
|
+
|
|
1275
|
+
ALTER TABLE ONLY public.plg_menu_modifiers
|
|
1276
|
+
ADD CONSTRAINT plg_menu_modifiers_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE;
|
|
1277
|
+
|
|
1278
|
+
ALTER TABLE ONLY public.plg_menu_placements
|
|
1279
|
+
ADD CONSTRAINT plg_menu_placements_item_id_fkey FOREIGN KEY (item_id) REFERENCES public.products(id) ON DELETE CASCADE;
|
|
1280
|
+
|
|
1281
|
+
ALTER TABLE ONLY public.plg_menu_placements
|
|
1282
|
+
ADD CONSTRAINT plg_menu_placements_section_id_fkey FOREIGN KEY (section_id) REFERENCES public.plg_menu_sections(id) ON DELETE CASCADE;
|
|
1283
|
+
|
|
1284
|
+
ALTER TABLE ONLY public.plg_menu_placements
|
|
1285
|
+
ADD CONSTRAINT plg_menu_placements_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE;
|
|
1286
|
+
|
|
1287
|
+
ALTER TABLE ONLY public.plg_menu_sections
|
|
1288
|
+
ADD CONSTRAINT plg_menu_sections_menu_id_fkey FOREIGN KEY (menu_id) REFERENCES public.plg_menu_menus(id) ON DELETE CASCADE;
|
|
1289
|
+
|
|
1290
|
+
ALTER TABLE ONLY public.plg_menu_sections
|
|
1291
|
+
ADD CONSTRAINT plg_menu_sections_tenant_id_fkey FOREIGN KEY (tenant_id) REFERENCES public.tenants(id) ON DELETE CASCADE;
|
|
1292
|
+
|
|
1293
|
+
|
|
1294
|
+
-- \u2500\u2500 row security \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
1295
|
+
|
|
1296
|
+
ALTER TABLE public.plg_menu_allergens ENABLE ROW LEVEL SECURITY;
|
|
1297
|
+
|
|
1151
1298
|
ALTER TABLE public.plg_menu_dietary_tags ENABLE ROW LEVEL SECURITY;
|
|
1152
|
-
CREATE INDEX IF NOT EXISTS idx_plg_menu_dietary_tags_tenant ON public.plg_menu_dietary_tags(tenant_id);
|
|
1153
|
-
|
|
1154
|
-
-- Canonical per-tenant RLS + grants for every table above.
|
|
1155
|
-
DO $$
|
|
1156
|
-
DECLARE t text;
|
|
1157
|
-
BEGIN
|
|
1158
|
-
FOR t IN SELECT unnest(ARRAY[
|
|
1159
|
-
'plg_menu_menus','plg_menu_sections','plg_menu_placements','plg_menu_items',
|
|
1160
|
-
'plg_menu_modifier_groups','plg_menu_modifiers','plg_menu_item_modifier_groups',
|
|
1161
|
-
'plg_menu_allergens','plg_menu_dietary_tags'
|
|
1162
|
-
])
|
|
1163
|
-
LOOP
|
|
1164
|
-
EXECUTE format('ALTER TABLE public.%I ENABLE ROW LEVEL SECURITY', t);
|
|
1165
|
-
EXECUTE format('GRANT SELECT, INSERT, UPDATE, DELETE ON public.%I TO authenticated', t);
|
|
1166
|
-
IF NOT EXISTS (SELECT 1 FROM pg_policies WHERE schemaname='public' AND tablename=t AND policyname=t||'_select') THEN
|
|
1167
|
-
EXECUTE format('CREATE POLICY %I ON public.%I FOR SELECT TO authenticated USING (tenant_id IN (SELECT public.user_tenant_ids()))', t||'_select', t);
|
|
1168
|
-
END IF;
|
|
1169
|
-
IF NOT EXISTS (SELECT 1 FROM pg_policies WHERE schemaname='public' AND tablename=t AND policyname=t||'_insert') THEN
|
|
1170
|
-
EXECUTE format('CREATE POLICY %I ON public.%I FOR INSERT TO authenticated WITH CHECK (tenant_id IN (SELECT public.user_tenant_ids()))', t||'_insert', t);
|
|
1171
|
-
END IF;
|
|
1172
|
-
IF NOT EXISTS (SELECT 1 FROM pg_policies WHERE schemaname='public' AND tablename=t AND policyname=t||'_update') THEN
|
|
1173
|
-
EXECUTE format('CREATE POLICY %I ON public.%I FOR UPDATE TO authenticated USING (tenant_id IN (SELECT public.user_tenant_ids()))', t||'_update', t);
|
|
1174
|
-
END IF;
|
|
1175
|
-
IF NOT EXISTS (SELECT 1 FROM pg_policies WHERE schemaname='public' AND tablename=t AND policyname=t||'_delete') THEN
|
|
1176
|
-
EXECUTE format('CREATE POLICY %I ON public.%I FOR DELETE TO authenticated USING (tenant_id IN (SELECT public.user_tenant_ids()))', t||'_delete', t);
|
|
1177
|
-
END IF;
|
|
1178
|
-
END LOOP;
|
|
1179
|
-
END $$;
|
|
1180
|
-
`;
|
|
1181
|
-
var MIGRATION_002_MENU_BACKFILL = `-- Menu Plugin: adopt whatever menu already exists in the pool.
|
|
1182
|
-
--
|
|
1183
|
-
-- Pools that ran the incubator version of this plugin have a flat world:
|
|
1184
|
-
-- categories in public.categories (kind='menu_category'), item flags in a
|
|
1185
|
-
-- public.menu_items extension, and no menus at all. Rather than ask the
|
|
1186
|
-
-- restaurant to type its menu again, the first menu is BUILT from that data:
|
|
1187
|
-
-- one "Card\xE1pio principal" per tenant, its sections are the old categories, and
|
|
1188
|
-
-- every product already sitting in a category takes its seat.
|
|
1189
|
-
--
|
|
1190
|
-
-- Every step is guarded twice: by the existence of the legacy object (a fresh
|
|
1191
|
-
-- pool has none of it) and by a NOT EXISTS on the target, so re-applying does
|
|
1192
|
-
-- nothing. The legacy tables are never written to or dropped \u2014 an app still
|
|
1193
|
-
-- reading them keeps working.
|
|
1194
|
-
|
|
1195
|
-
DO $$
|
|
1196
|
-
DECLARE
|
|
1197
|
-
has_categories boolean := to_regclass('public.categories') IS NOT NULL;
|
|
1198
|
-
has_legacy_items boolean := to_regclass('public.menu_items') IS NOT NULL;
|
|
1199
|
-
has_products boolean := to_regclass('public.products') IS NOT NULL;
|
|
1200
|
-
has_category_kind boolean := EXISTS (
|
|
1201
|
-
SELECT 1 FROM information_schema.columns
|
|
1202
|
-
WHERE table_schema='public' AND table_name='categories' AND column_name='kind'
|
|
1203
|
-
);
|
|
1204
|
-
has_product_category boolean := EXISTS (
|
|
1205
|
-
SELECT 1 FROM information_schema.columns
|
|
1206
|
-
WHERE table_schema='public' AND table_name='products' AND column_name='category_id'
|
|
1207
|
-
);
|
|
1208
|
-
BEGIN
|
|
1209
|
-
-- 1. One default menu per tenant that has menu categories or menu items.
|
|
1210
|
-
IF has_categories AND has_category_kind THEN
|
|
1211
|
-
EXECUTE $sql$
|
|
1212
|
-
INSERT INTO public.plg_menu_menus (tenant_id, name, description, sort_order)
|
|
1213
|
-
SELECT DISTINCT c.tenant_id, 'Card\xE1pio principal', NULL, 0
|
|
1214
|
-
FROM public.categories c
|
|
1215
|
-
WHERE c.kind = 'menu_category'
|
|
1216
|
-
AND c.tenant_id IS NOT NULL
|
|
1217
|
-
AND NOT EXISTS (SELECT 1 FROM public.plg_menu_menus m WHERE m.tenant_id = c.tenant_id)
|
|
1218
|
-
$sql$;
|
|
1219
|
-
END IF;
|
|
1220
|
-
|
|
1221
|
-
IF has_legacy_items THEN
|
|
1222
|
-
EXECUTE $sql$
|
|
1223
|
-
INSERT INTO public.plg_menu_menus (tenant_id, name, description, sort_order)
|
|
1224
|
-
SELECT DISTINCT mi.tenant_id, 'Card\xE1pio principal', NULL, 0
|
|
1225
|
-
FROM public.menu_items mi
|
|
1226
|
-
WHERE mi.tenant_id IS NOT NULL
|
|
1227
|
-
AND NOT EXISTS (SELECT 1 FROM public.plg_menu_menus m WHERE m.tenant_id = mi.tenant_id)
|
|
1228
|
-
$sql$;
|
|
1229
|
-
END IF;
|
|
1230
|
-
|
|
1231
|
-
-- 2. Sections from the flat categories, keeping name and order.
|
|
1232
|
-
IF has_categories AND has_category_kind THEN
|
|
1233
|
-
EXECUTE $sql$
|
|
1234
|
-
INSERT INTO public.plg_menu_sections (tenant_id, menu_id, name, sort_order, is_active, legacy_category_id)
|
|
1235
|
-
SELECT c.tenant_id, m.id, c.name,
|
|
1236
|
-
COALESCE(NULLIF(c.sort_order, 0), row_number() OVER (PARTITION BY c.tenant_id ORDER BY c.sort_order, c.name)),
|
|
1237
|
-
COALESCE(c.is_active, true), c.id
|
|
1238
|
-
FROM public.categories c
|
|
1239
|
-
JOIN public.plg_menu_menus m
|
|
1240
|
-
ON m.tenant_id = c.tenant_id AND m.sort_order = 0
|
|
1241
|
-
WHERE c.kind = 'menu_category'
|
|
1242
|
-
AND NOT EXISTS (
|
|
1243
|
-
SELECT 1 FROM public.plg_menu_sections s
|
|
1244
|
-
WHERE s.menu_id = m.id AND s.legacy_category_id = c.id
|
|
1245
|
-
)
|
|
1246
|
-
$sql$;
|
|
1247
|
-
END IF;
|
|
1248
|
-
|
|
1249
|
-
-- 3. Seat every product that already belongs to one of those categories.
|
|
1250
|
-
IF has_products AND has_product_category AND has_categories AND has_category_kind THEN
|
|
1251
|
-
EXECUTE $sql$
|
|
1252
|
-
INSERT INTO public.plg_menu_placements (tenant_id, section_id, item_id, sort_order)
|
|
1253
|
-
SELECT p.tenant_id, s.id, p.id,
|
|
1254
|
-
row_number() OVER (PARTITION BY s.id ORDER BY p.name)
|
|
1255
|
-
FROM public.products p
|
|
1256
|
-
JOIN public.plg_menu_sections s ON s.legacy_category_id = p.category_id AND s.tenant_id = p.tenant_id
|
|
1257
|
-
WHERE NOT EXISTS (
|
|
1258
|
-
SELECT 1 FROM public.plg_menu_placements pl
|
|
1259
|
-
WHERE pl.section_id = s.id AND pl.item_id = p.id
|
|
1260
|
-
)
|
|
1261
|
-
$sql$;
|
|
1262
|
-
END IF;
|
|
1263
|
-
|
|
1264
|
-
-- 4. Carry the menu-specific item flags over from the legacy extension.
|
|
1265
|
-
IF has_legacy_items THEN
|
|
1266
|
-
EXECUTE $sql$
|
|
1267
|
-
INSERT INTO public.plg_menu_items (
|
|
1268
|
-
product_id, tenant_id, status, available_for_pos, available_for_delivery,
|
|
1269
|
-
delivery_price, prep_time_minutes, allergens, dietary_tags, is_featured, sort_order
|
|
1270
|
-
)
|
|
1271
|
-
SELECT mi.product_id, mi.tenant_id,
|
|
1272
|
-
COALESCE(mi.status, 'available'),
|
|
1273
|
-
COALESCE(mi.available_for_pos, true),
|
|
1274
|
-
COALESCE(mi.available_for_delivery, true),
|
|
1275
|
-
mi.delivery_price, mi.prep_time_minutes,
|
|
1276
|
-
COALESCE(mi.allergens, ARRAY[]::text[]),
|
|
1277
|
-
COALESCE(mi.dietary_tags, ARRAY[]::text[]),
|
|
1278
|
-
COALESCE(mi.is_featured, false),
|
|
1279
|
-
COALESCE(mi.sort_order, 0)
|
|
1280
|
-
FROM public.menu_items mi
|
|
1281
|
-
WHERE mi.tenant_id IS NOT NULL
|
|
1282
|
-
ON CONFLICT (product_id) DO NOTHING
|
|
1283
|
-
$sql$;
|
|
1284
|
-
END IF;
|
|
1285
|
-
END $$;
|
|
1286
|
-
|
|
1287
|
-
-- Seed the allergen / dietary registries once per tenant that has a menu.
|
|
1288
|
-
INSERT INTO public.plg_menu_allergens (tenant_id, name, icon)
|
|
1289
|
-
SELECT m.tenant_id, v.name, v.icon
|
|
1290
|
-
FROM (SELECT DISTINCT tenant_id FROM public.plg_menu_menus) m
|
|
1291
|
-
CROSS JOIN (VALUES
|
|
1292
|
-
('Gl\xFAten', 'Wheat'), ('Lactose', 'Milk'), ('Ovos', 'Egg'),
|
|
1293
|
-
('Amendoim', 'Nut'), ('Frutos do mar', 'Fish'), ('Soja', 'Bean')
|
|
1294
|
-
) AS v(name, icon)
|
|
1295
|
-
WHERE NOT EXISTS (
|
|
1296
|
-
SELECT 1 FROM public.plg_menu_allergens a WHERE a.tenant_id = m.tenant_id AND a.name = v.name
|
|
1297
|
-
);
|
|
1298
1299
|
|
|
1299
|
-
|
|
1300
|
-
SELECT m.tenant_id, v.name, v.color
|
|
1301
|
-
FROM (SELECT DISTINCT tenant_id FROM public.plg_menu_menus) m
|
|
1302
|
-
CROSS JOIN (VALUES
|
|
1303
|
-
('Vegetariano', 'green'), ('Vegano', 'emerald'), ('Sem gl\xFAten', 'amber')
|
|
1304
|
-
) AS v(name, color)
|
|
1305
|
-
WHERE NOT EXISTS (
|
|
1306
|
-
SELECT 1 FROM public.plg_menu_dietary_tags d WHERE d.tenant_id = m.tenant_id AND d.name = v.name
|
|
1307
|
-
);
|
|
1308
|
-
`;
|
|
1309
|
-
var MIGRATION_003_MENU_STORAGE = `-- Menu Plugin: bucket for item, section and import photos.
|
|
1310
|
-
--
|
|
1311
|
-
-- Public on read: these images are the menu the customer looks at, and a signed
|
|
1312
|
-
-- URL per dish would mean re-signing the whole menu on every render. Writing is
|
|
1313
|
-
-- the guarded half \u2014 only a member of the tenant whose folder it is.
|
|
1314
|
-
-- Path grammar: {tenant_id}/{item|section|menu|import}/{uuid}.{ext}
|
|
1315
|
-
|
|
1316
|
-
INSERT INTO storage.buckets (id, name, public, file_size_limit, allowed_mime_types)
|
|
1317
|
-
VALUES (
|
|
1318
|
-
'menu-images',
|
|
1319
|
-
'menu-images',
|
|
1320
|
-
true,
|
|
1321
|
-
8388608, -- 8 MB: a phone photo of a menu page, already compressed by the client
|
|
1322
|
-
ARRAY['image/jpeg','image/png','image/webp','image/heic','image/heif']
|
|
1323
|
-
)
|
|
1324
|
-
ON CONFLICT (id) DO UPDATE SET
|
|
1325
|
-
public = EXCLUDED.public,
|
|
1326
|
-
file_size_limit = EXCLUDED.file_size_limit,
|
|
1327
|
-
allowed_mime_types = EXCLUDED.allowed_mime_types;
|
|
1328
|
-
|
|
1329
|
-
DROP POLICY IF EXISTS plg_menu_images_read ON storage.objects;
|
|
1330
|
-
DROP POLICY IF EXISTS plg_menu_images_insert ON storage.objects;
|
|
1331
|
-
DROP POLICY IF EXISTS plg_menu_images_update ON storage.objects;
|
|
1332
|
-
DROP POLICY IF EXISTS plg_menu_images_delete ON storage.objects;
|
|
1333
|
-
|
|
1334
|
-
CREATE POLICY plg_menu_images_read ON storage.objects
|
|
1335
|
-
FOR SELECT TO anon, authenticated
|
|
1336
|
-
USING (bucket_id = 'menu-images');
|
|
1337
|
-
|
|
1338
|
-
CREATE POLICY plg_menu_images_insert ON storage.objects
|
|
1339
|
-
FOR INSERT TO authenticated
|
|
1340
|
-
WITH CHECK (
|
|
1341
|
-
bucket_id = 'menu-images'
|
|
1342
|
-
AND (storage.foldername(name))[1] IN (SELECT public.user_tenant_ids()::text)
|
|
1343
|
-
);
|
|
1300
|
+
ALTER TABLE public.plg_menu_item_modifier_groups ENABLE ROW LEVEL SECURITY;
|
|
1344
1301
|
|
|
1345
|
-
|
|
1346
|
-
FOR UPDATE TO authenticated
|
|
1347
|
-
USING (
|
|
1348
|
-
bucket_id = 'menu-images'
|
|
1349
|
-
AND (storage.foldername(name))[1] IN (SELECT public.user_tenant_ids()::text)
|
|
1350
|
-
);
|
|
1302
|
+
ALTER TABLE public.plg_menu_items ENABLE ROW LEVEL SECURITY;
|
|
1351
1303
|
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
--
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1304
|
+
ALTER TABLE public.plg_menu_menus ENABLE ROW LEVEL SECURITY;
|
|
1305
|
+
|
|
1306
|
+
ALTER TABLE public.plg_menu_modifier_groups ENABLE ROW LEVEL SECURITY;
|
|
1307
|
+
|
|
1308
|
+
ALTER TABLE public.plg_menu_modifiers ENABLE ROW LEVEL SECURITY;
|
|
1309
|
+
|
|
1310
|
+
ALTER TABLE public.plg_menu_placements ENABLE ROW LEVEL SECURITY;
|
|
1311
|
+
|
|
1312
|
+
ALTER TABLE public.plg_menu_sections ENABLE ROW LEVEL SECURITY;
|
|
1313
|
+
|
|
1314
|
+
|
|
1315
|
+
-- \u2500\u2500 policy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
1316
|
+
|
|
1317
|
+
CREATE POLICY plg_menu_allergens_delete ON public.plg_menu_allergens FOR DELETE TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1318
|
+
|
|
1319
|
+
CREATE POLICY plg_menu_allergens_insert ON public.plg_menu_allergens FOR INSERT TO authenticated WITH CHECK ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1320
|
+
|
|
1321
|
+
CREATE POLICY plg_menu_allergens_select ON public.plg_menu_allergens FOR SELECT TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1322
|
+
|
|
1323
|
+
CREATE POLICY plg_menu_allergens_update ON public.plg_menu_allergens FOR UPDATE TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1324
|
+
|
|
1325
|
+
CREATE POLICY plg_menu_dietary_tags_delete ON public.plg_menu_dietary_tags FOR DELETE TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1326
|
+
|
|
1327
|
+
CREATE POLICY plg_menu_dietary_tags_insert ON public.plg_menu_dietary_tags FOR INSERT TO authenticated WITH CHECK ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1328
|
+
|
|
1329
|
+
CREATE POLICY plg_menu_dietary_tags_select ON public.plg_menu_dietary_tags FOR SELECT TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1330
|
+
|
|
1331
|
+
CREATE POLICY plg_menu_dietary_tags_update ON public.plg_menu_dietary_tags FOR UPDATE TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1332
|
+
|
|
1333
|
+
CREATE POLICY plg_menu_item_modifier_groups_delete ON public.plg_menu_item_modifier_groups FOR DELETE TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1334
|
+
|
|
1335
|
+
CREATE POLICY plg_menu_item_modifier_groups_insert ON public.plg_menu_item_modifier_groups FOR INSERT TO authenticated WITH CHECK ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1336
|
+
|
|
1337
|
+
CREATE POLICY plg_menu_item_modifier_groups_select ON public.plg_menu_item_modifier_groups FOR SELECT TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1338
|
+
|
|
1339
|
+
CREATE POLICY plg_menu_item_modifier_groups_update ON public.plg_menu_item_modifier_groups FOR UPDATE TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1340
|
+
|
|
1341
|
+
CREATE POLICY plg_menu_items_delete ON public.plg_menu_items FOR DELETE TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1342
|
+
|
|
1343
|
+
CREATE POLICY plg_menu_items_insert ON public.plg_menu_items FOR INSERT TO authenticated WITH CHECK ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1344
|
+
|
|
1345
|
+
CREATE POLICY plg_menu_items_select ON public.plg_menu_items FOR SELECT TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1346
|
+
|
|
1347
|
+
CREATE POLICY plg_menu_items_update ON public.plg_menu_items FOR UPDATE TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1348
|
+
|
|
1349
|
+
CREATE POLICY plg_menu_menus_delete ON public.plg_menu_menus FOR DELETE TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1350
|
+
|
|
1351
|
+
CREATE POLICY plg_menu_menus_insert ON public.plg_menu_menus FOR INSERT TO authenticated WITH CHECK ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1352
|
+
|
|
1353
|
+
CREATE POLICY plg_menu_menus_select ON public.plg_menu_menus FOR SELECT TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1354
|
+
|
|
1355
|
+
CREATE POLICY plg_menu_menus_update ON public.plg_menu_menus FOR UPDATE TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1356
|
+
|
|
1357
|
+
CREATE POLICY plg_menu_modifier_groups_delete ON public.plg_menu_modifier_groups FOR DELETE TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1358
|
+
|
|
1359
|
+
CREATE POLICY plg_menu_modifier_groups_insert ON public.plg_menu_modifier_groups FOR INSERT TO authenticated WITH CHECK ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1360
|
+
|
|
1361
|
+
CREATE POLICY plg_menu_modifier_groups_select ON public.plg_menu_modifier_groups FOR SELECT TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1362
|
+
|
|
1363
|
+
CREATE POLICY plg_menu_modifier_groups_update ON public.plg_menu_modifier_groups FOR UPDATE TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1364
|
+
|
|
1365
|
+
CREATE POLICY plg_menu_modifiers_delete ON public.plg_menu_modifiers FOR DELETE TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1366
|
+
|
|
1367
|
+
CREATE POLICY plg_menu_modifiers_insert ON public.plg_menu_modifiers FOR INSERT TO authenticated WITH CHECK ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1368
|
+
|
|
1369
|
+
CREATE POLICY plg_menu_modifiers_select ON public.plg_menu_modifiers FOR SELECT TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1370
|
+
|
|
1371
|
+
CREATE POLICY plg_menu_modifiers_update ON public.plg_menu_modifiers FOR UPDATE TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1372
|
+
|
|
1373
|
+
CREATE POLICY plg_menu_placements_delete ON public.plg_menu_placements FOR DELETE TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1374
|
+
|
|
1375
|
+
CREATE POLICY plg_menu_placements_insert ON public.plg_menu_placements FOR INSERT TO authenticated WITH CHECK ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1376
|
+
|
|
1377
|
+
CREATE POLICY plg_menu_placements_select ON public.plg_menu_placements FOR SELECT TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1378
|
+
|
|
1379
|
+
CREATE POLICY plg_menu_placements_update ON public.plg_menu_placements FOR UPDATE TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1380
|
+
|
|
1381
|
+
CREATE POLICY plg_menu_sections_delete ON public.plg_menu_sections FOR DELETE TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1382
|
+
|
|
1383
|
+
CREATE POLICY plg_menu_sections_insert ON public.plg_menu_sections FOR INSERT TO authenticated WITH CHECK ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1384
|
+
|
|
1385
|
+
CREATE POLICY plg_menu_sections_select ON public.plg_menu_sections FOR SELECT TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1386
|
+
|
|
1387
|
+
CREATE POLICY plg_menu_sections_update ON public.plg_menu_sections FOR UPDATE TO authenticated USING ((tenant_id IN ( SELECT public.user_tenant_ids() AS user_tenant_ids)));
|
|
1388
|
+
|
|
1389
|
+
|
|
1390
|
+
-- \u2500\u2500 acl \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
1391
|
+
|
|
1392
|
+
GRANT MAINTAIN ON TABLE public.plg_menu_allergens TO anon;
|
|
1393
|
+
GRANT ALL ON TABLE public.plg_menu_allergens TO authenticated;
|
|
1394
|
+
GRANT ALL ON TABLE public.plg_menu_allergens TO service_role;
|
|
1395
|
+
|
|
1396
|
+
GRANT MAINTAIN ON TABLE public.plg_menu_dietary_tags TO anon;
|
|
1397
|
+
GRANT ALL ON TABLE public.plg_menu_dietary_tags TO authenticated;
|
|
1398
|
+
GRANT ALL ON TABLE public.plg_menu_dietary_tags TO service_role;
|
|
1399
|
+
|
|
1400
|
+
GRANT MAINTAIN ON TABLE public.plg_menu_item_modifier_groups TO anon;
|
|
1401
|
+
GRANT ALL ON TABLE public.plg_menu_item_modifier_groups TO authenticated;
|
|
1402
|
+
GRANT ALL ON TABLE public.plg_menu_item_modifier_groups TO service_role;
|
|
1403
|
+
|
|
1404
|
+
GRANT MAINTAIN ON TABLE public.plg_menu_items TO anon;
|
|
1405
|
+
GRANT ALL ON TABLE public.plg_menu_items TO authenticated;
|
|
1406
|
+
GRANT ALL ON TABLE public.plg_menu_items TO service_role;
|
|
1407
|
+
|
|
1408
|
+
GRANT MAINTAIN ON TABLE public.plg_menu_menus TO anon;
|
|
1409
|
+
GRANT ALL ON TABLE public.plg_menu_menus TO authenticated;
|
|
1410
|
+
GRANT ALL ON TABLE public.plg_menu_menus TO service_role;
|
|
1411
|
+
|
|
1412
|
+
GRANT MAINTAIN ON TABLE public.plg_menu_modifier_groups TO anon;
|
|
1413
|
+
GRANT ALL ON TABLE public.plg_menu_modifier_groups TO authenticated;
|
|
1414
|
+
GRANT ALL ON TABLE public.plg_menu_modifier_groups TO service_role;
|
|
1415
|
+
|
|
1416
|
+
GRANT MAINTAIN ON TABLE public.plg_menu_modifiers TO anon;
|
|
1417
|
+
GRANT ALL ON TABLE public.plg_menu_modifiers TO authenticated;
|
|
1418
|
+
GRANT ALL ON TABLE public.plg_menu_modifiers TO service_role;
|
|
1419
|
+
|
|
1420
|
+
GRANT MAINTAIN ON TABLE public.plg_menu_placements TO anon;
|
|
1421
|
+
GRANT ALL ON TABLE public.plg_menu_placements TO authenticated;
|
|
1422
|
+
GRANT ALL ON TABLE public.plg_menu_placements TO service_role;
|
|
1423
|
+
|
|
1424
|
+
GRANT MAINTAIN ON TABLE public.plg_menu_sections TO anon;
|
|
1425
|
+
GRANT ALL ON TABLE public.plg_menu_sections TO authenticated;
|
|
1426
|
+
GRANT ALL ON TABLE public.plg_menu_sections TO service_role;
|
|
1427
|
+
|
|
1428
|
+
|
|
1429
|
+
-- \u2500\u2500 default privileges: restore \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
1430
|
+
-- Put back, so the NEXT thing installed inherits what the chain had.
|
|
1431
|
+
|
|
1432
|
+
DO $dp$ BEGIN
|
|
1433
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO postgres$stmt$;
|
|
1434
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1435
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO postgres$stmt$;
|
|
1436
|
+
END $dp$;
|
|
1437
|
+
|
|
1438
|
+
DO $dp$ BEGIN
|
|
1439
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO anon$stmt$;
|
|
1440
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1441
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO anon$stmt$;
|
|
1442
|
+
END $dp$;
|
|
1443
|
+
|
|
1444
|
+
DO $dp$ BEGIN
|
|
1445
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticated$stmt$;
|
|
1446
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1447
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticated$stmt$;
|
|
1448
|
+
END $dp$;
|
|
1449
|
+
|
|
1450
|
+
DO $dp$ BEGIN
|
|
1451
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO service_role$stmt$;
|
|
1452
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1453
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON SEQUENCES TO service_role$stmt$;
|
|
1454
|
+
END $dp$;
|
|
1455
|
+
|
|
1456
|
+
DO $dp$ BEGIN
|
|
1457
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO postgres$stmt$;
|
|
1458
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1459
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO postgres$stmt$;
|
|
1460
|
+
END $dp$;
|
|
1461
|
+
|
|
1462
|
+
DO $dp$ BEGIN
|
|
1463
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO anon$stmt$;
|
|
1464
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1465
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO anon$stmt$;
|
|
1466
|
+
END $dp$;
|
|
1467
|
+
|
|
1468
|
+
DO $dp$ BEGIN
|
|
1469
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticated$stmt$;
|
|
1470
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1471
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO authenticated$stmt$;
|
|
1472
|
+
END $dp$;
|
|
1473
|
+
|
|
1474
|
+
DO $dp$ BEGIN
|
|
1475
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO service_role$stmt$;
|
|
1476
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1477
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON SEQUENCES TO service_role$stmt$;
|
|
1478
|
+
END $dp$;
|
|
1479
|
+
|
|
1480
|
+
DO $dp$ BEGIN
|
|
1481
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON FUNCTIONS TO postgres$stmt$;
|
|
1482
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1483
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON FUNCTIONS TO postgres$stmt$;
|
|
1484
|
+
END $dp$;
|
|
1485
|
+
|
|
1486
|
+
DO $dp$ BEGIN
|
|
1487
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON FUNCTIONS TO authenticated$stmt$;
|
|
1488
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1489
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON FUNCTIONS TO authenticated$stmt$;
|
|
1490
|
+
END $dp$;
|
|
1491
|
+
|
|
1492
|
+
DO $dp$ BEGIN
|
|
1493
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON FUNCTIONS TO service_role$stmt$;
|
|
1494
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1495
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON FUNCTIONS TO service_role$stmt$;
|
|
1496
|
+
END $dp$;
|
|
1497
|
+
|
|
1498
|
+
DO $dp$ BEGIN
|
|
1499
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO postgres$stmt$;
|
|
1500
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1501
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO postgres$stmt$;
|
|
1502
|
+
END $dp$;
|
|
1503
|
+
|
|
1504
|
+
DO $dp$ BEGIN
|
|
1505
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO anon$stmt$;
|
|
1506
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1507
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO anon$stmt$;
|
|
1508
|
+
END $dp$;
|
|
1509
|
+
|
|
1510
|
+
DO $dp$ BEGIN
|
|
1511
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO authenticated$stmt$;
|
|
1512
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1513
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO authenticated$stmt$;
|
|
1514
|
+
END $dp$;
|
|
1515
|
+
|
|
1516
|
+
DO $dp$ BEGIN
|
|
1517
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO service_role$stmt$;
|
|
1518
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1519
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON FUNCTIONS TO service_role$stmt$;
|
|
1520
|
+
END $dp$;
|
|
1521
|
+
|
|
1522
|
+
DO $dp$ BEGIN
|
|
1523
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO postgres$stmt$;
|
|
1524
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1525
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO postgres$stmt$;
|
|
1526
|
+
END $dp$;
|
|
1527
|
+
|
|
1528
|
+
DO $dp$ BEGIN
|
|
1529
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT MAINTAIN ON TABLES TO anon$stmt$;
|
|
1530
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1531
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT MAINTAIN ON TABLES TO anon$stmt$;
|
|
1532
|
+
END $dp$;
|
|
1533
|
+
|
|
1534
|
+
DO $dp$ BEGIN
|
|
1535
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO authenticated$stmt$;
|
|
1536
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1537
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO authenticated$stmt$;
|
|
1538
|
+
END $dp$;
|
|
1539
|
+
|
|
1540
|
+
DO $dp$ BEGIN
|
|
1541
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO service_role$stmt$;
|
|
1542
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1543
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE postgres IN SCHEMA public GRANT ALL ON TABLES TO service_role$stmt$;
|
|
1544
|
+
END $dp$;
|
|
1545
|
+
|
|
1546
|
+
DO $dp$ BEGIN
|
|
1547
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO postgres$stmt$;
|
|
1548
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1549
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO postgres$stmt$;
|
|
1550
|
+
END $dp$;
|
|
1551
|
+
|
|
1552
|
+
DO $dp$ BEGIN
|
|
1553
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO anon$stmt$;
|
|
1554
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1555
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO anon$stmt$;
|
|
1556
|
+
END $dp$;
|
|
1557
|
+
|
|
1558
|
+
DO $dp$ BEGIN
|
|
1559
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO authenticated$stmt$;
|
|
1560
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1561
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO authenticated$stmt$;
|
|
1562
|
+
END $dp$;
|
|
1563
|
+
|
|
1564
|
+
DO $dp$ BEGIN
|
|
1565
|
+
EXECUTE $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO service_role$stmt$;
|
|
1566
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1567
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT ALL ON TABLES TO service_role$stmt$;
|
|
1568
|
+
END $dp$;
|
|
1569
|
+
|
|
1570
|
+
DO $dp$ BEGIN
|
|
1571
|
+
EXECUTE $stmt$--
|
|
1572
|
+
-- PostgreSQL database dump complete
|
|
1573
|
+
--$stmt$;
|
|
1574
|
+
EXCEPTION WHEN insufficient_privilege OR undefined_object THEN
|
|
1575
|
+
RAISE NOTICE 'baseline: not ours to set \u2014 %', $stmt$--
|
|
1576
|
+
-- PostgreSQL database dump complete
|
|
1577
|
+
--$stmt$;
|
|
1578
|
+
END $dp$;
|
|
1381
1579
|
`;
|
|
1382
1580
|
var MIGRATIONS = [
|
|
1383
|
-
{ id: "
|
|
1384
|
-
{ id: "002_menu_backfill", sql: MIGRATION_002_MENU_BACKFILL },
|
|
1385
|
-
{ id: "003_menu_storage", sql: MIGRATION_003_MENU_STORAGE },
|
|
1386
|
-
{ id: "004_the_menu_declares_its_species", sql: MIGRATION_004_THE_MENU_DECLARES_ITS_SPECIES }
|
|
1581
|
+
{ id: "000_baseline", sql: MIGRATION_000_BASELINE }
|
|
1387
1582
|
];
|
|
1388
1583
|
|
|
1389
1584
|
// src/data/types.ts
|
|
@@ -1395,6 +1590,7 @@ function supportsMenus(provider) {
|
|
|
1395
1590
|
var LEGACY_MENU_ID = "__default__";
|
|
1396
1591
|
var placementId = (itemId) => `legacy:${itemId}`;
|
|
1397
1592
|
var itemIdOf = (placement) => placement.replace(/^legacy:/, "");
|
|
1593
|
+
var UNFILED_SECTION_ID = "__unfiled__";
|
|
1398
1594
|
function unsupported(what) {
|
|
1399
1595
|
throw new Error(`[menu] This workspace's menu backend does not support ${what} yet.`);
|
|
1400
1596
|
}
|
|
@@ -1439,8 +1635,8 @@ function wrapLegacyProvider(provider) {
|
|
|
1439
1635
|
async reorderMenus() {
|
|
1440
1636
|
},
|
|
1441
1637
|
async getSections() {
|
|
1442
|
-
const categories = await provider.getCategories();
|
|
1443
|
-
|
|
1638
|
+
const [categories, items] = await Promise.all([provider.getCategories(), allItems()]);
|
|
1639
|
+
const sections = categories.map((c) => ({
|
|
1444
1640
|
id: c.id,
|
|
1445
1641
|
menuId: LEGACY_MENU_ID,
|
|
1446
1642
|
name: c.name,
|
|
@@ -1450,6 +1646,20 @@ function wrapLegacyProvider(provider) {
|
|
|
1450
1646
|
createdAt: c.createdAt,
|
|
1451
1647
|
updatedAt: c.updatedAt
|
|
1452
1648
|
}));
|
|
1649
|
+
const unfiled = items.filter((i) => !i.categoryId);
|
|
1650
|
+
if (unfiled.length > 0) {
|
|
1651
|
+
sections.push({
|
|
1652
|
+
id: UNFILED_SECTION_ID,
|
|
1653
|
+
menuId: LEGACY_MENU_ID,
|
|
1654
|
+
name: "Sem se\xE7\xE3o",
|
|
1655
|
+
sortOrder: Number.MAX_SAFE_INTEGER,
|
|
1656
|
+
isActive: true,
|
|
1657
|
+
tenantId: unfiled[0].tenantId,
|
|
1658
|
+
createdAt: unfiled[0].createdAt,
|
|
1659
|
+
updatedAt: unfiled[0].updatedAt
|
|
1660
|
+
});
|
|
1661
|
+
}
|
|
1662
|
+
return sections;
|
|
1453
1663
|
},
|
|
1454
1664
|
async createSection(input) {
|
|
1455
1665
|
const category = await provider.createCategory({ name: input.name, sortOrder: input.sortOrder });
|
|
@@ -1489,17 +1699,36 @@ function wrapLegacyProvider(provider) {
|
|
|
1489
1699
|
},
|
|
1490
1700
|
async getPlacements() {
|
|
1491
1701
|
const items = await allItems();
|
|
1492
|
-
return items.
|
|
1702
|
+
return items.map((item) => ({
|
|
1493
1703
|
id: placementId(item.id),
|
|
1494
|
-
sectionId: item.categoryId,
|
|
1704
|
+
sectionId: item.categoryId ?? UNFILED_SECTION_ID,
|
|
1495
1705
|
itemId: item.id,
|
|
1496
1706
|
sortOrder: item.sortOrder ?? 0,
|
|
1497
1707
|
isActive: item.status !== "hidden",
|
|
1498
1708
|
tenantId: item.tenantId
|
|
1499
1709
|
}));
|
|
1500
1710
|
},
|
|
1711
|
+
/**
|
|
1712
|
+
* The section the user clicked, honoured.
|
|
1713
|
+
*
|
|
1714
|
+
* The store calls `createMenuItem({ ...input, sectionId })` — the section is
|
|
1715
|
+
* already carried from the "Adicionar item" button. A legacy provider reads
|
|
1716
|
+
* `categoryId` and knows nothing about sections, so it dropped it and the
|
|
1717
|
+
* new dish landed unfiled: created correctly, then invisible, because a
|
|
1718
|
+
* legacy item's seat IS its category.
|
|
1719
|
+
*
|
|
1720
|
+
* Translating one into the other is this adapter's whole job. No section
|
|
1721
|
+
* clicked (the item rail, an import) still means no category, and the
|
|
1722
|
+
* unfiled bucket is what shows it.
|
|
1723
|
+
*/
|
|
1724
|
+
async createMenuItem(input) {
|
|
1725
|
+
const { sectionId, ...rest } = input;
|
|
1726
|
+
const categoryId = sectionId && sectionId !== UNFILED_SECTION_ID ? sectionId : rest.categoryId;
|
|
1727
|
+
return provider.createMenuItem({ ...rest, categoryId });
|
|
1728
|
+
},
|
|
1501
1729
|
async placeItem(input) {
|
|
1502
|
-
|
|
1730
|
+
const categoryId = input.sectionId === UNFILED_SECTION_ID ? null : input.sectionId;
|
|
1731
|
+
await provider.updateMenuItem(input.itemId, { categoryId });
|
|
1503
1732
|
return {
|
|
1504
1733
|
id: placementId(input.itemId),
|
|
1505
1734
|
sectionId: input.sectionId,
|
|
@@ -2047,7 +2276,7 @@ var dietaryTagEntity = {
|
|
|
2047
2276
|
defaultSort: "name",
|
|
2048
2277
|
fields: [
|
|
2049
2278
|
{ key: "name", label: "Name", type: "text", required: true, showInTable: true },
|
|
2050
|
-
{ key: "color", label: "Color", type: "
|
|
2279
|
+
{ key: "color", label: "Color", type: "color", showInTable: true },
|
|
2051
2280
|
{ key: "isActive", label: "Active", type: "boolean", showInTable: true, defaultValue: true }
|
|
2052
2281
|
],
|
|
2053
2282
|
data: { table: T.dietaryTags, tenantScoped: true }
|
|
@@ -2509,7 +2738,7 @@ function itemUpdatePayload(input, existing) {
|
|
|
2509
2738
|
payload.is_active = input.status !== "hidden";
|
|
2510
2739
|
}
|
|
2511
2740
|
if (input.dietaryTags !== void 0) payload.tags = input.dietaryTags;
|
|
2512
|
-
payload.metadata = itemMetadata(input, existing?.metadata);
|
|
2741
|
+
payload.metadata = itemMetadata({ ...input, categoryId: input.categoryId ?? void 0 }, existing?.metadata);
|
|
2513
2742
|
return payload;
|
|
2514
2743
|
}
|
|
2515
2744
|
function matchesClientQuery(item, query) {
|
|
@@ -2717,7 +2946,7 @@ function createFayzMenuProvider(options = {}) {
|
|
|
2717
2946
|
}
|
|
2718
2947
|
|
|
2719
2948
|
// src/index.ts
|
|
2720
|
-
var MenuPage = React.lazy(() => import('./MenuPage-
|
|
2949
|
+
var MenuPage = React.lazy(() => import('./MenuPage-ZFBHFDZI.js').then((m) => ({ default: m.MenuPage })));
|
|
2721
2950
|
var DEFAULT_LABELS = {
|
|
2722
2951
|
pageTitle: "Menu",
|
|
2723
2952
|
menuManager: "Menu Manager",
|