RELEASE V.1.2.0 - Voici les fonctionnalités :
-> Mode sombre -> Updater -> Patch Host
This commit is contained in:
1 parent
5467ea3578
commit
e017166cb5
17 files changed
+7203
-7
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,12 @@
|
||||
-- 1. Donner l'accès au schéma public
|
||||
GRANT USAGE ON SCHEMA public TO anon, authenticated, service_role;
|
||||
|
||||
-- 2. Donner les droits CRUD (Create, Read, Update, Delete) sur TOUTES les tables existantes
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO anon, authenticated, service_role;
|
||||
|
||||
-- 3. Donner les droits sur TOUTES les séquences (indispensable pour les ID auto-incrémentés)
|
||||
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO anon, authenticated, service_role;
|
||||
|
||||
-- 4. S'assurer que les tables créées DANS LE FUTUR auront aussi ces droits
|
||||
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO anon, authenticated, service_role;
|
||||
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT USAGE, SELECT ON SEQUENCES TO anon, authenticated, service_role;
|
||||
@@ -0,0 +1,76 @@
|
||||
-- 1. Supprimer les fonctions qui dépendent du type ENUM
|
||||
DROP FUNCTION IF EXISTS "public"."get_gare_details"("uuid");
|
||||
DROP FUNCTION IF EXISTS "public"."get_station_details"("uuid");
|
||||
|
||||
-- 2. Modifier la colonne "type" de la table "gares" pour qu'elle devienne un VARCHAR
|
||||
ALTER TABLE "public"."gares" ALTER COLUMN "type" DROP DEFAULT;
|
||||
ALTER TABLE "public"."gares" ALTER COLUMN "type" TYPE VARCHAR(50) USING "type"::text;
|
||||
ALTER TABLE "public"."gares" ALTER COLUMN "type" SET DEFAULT 'ville'::character varying;
|
||||
|
||||
-- 3. Si la table "stations" existe (elle est mentionnée dans get_station_details), la modifier aussi
|
||||
DO $$
|
||||
BEGIN
|
||||
IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'stations') THEN
|
||||
ALTER TABLE "public"."stations" ALTER COLUMN "type" DROP DEFAULT;
|
||||
ALTER TABLE "public"."stations" ALTER COLUMN "type" TYPE VARCHAR(50) USING "type"::text;
|
||||
ALTER TABLE "public"."stations" ALTER COLUMN "type" SET DEFAULT 'ville'::character varying;
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
-- 4. Recréer les fonctions avec le type VARCHAR(50) au lieu de station_type
|
||||
CREATE OR REPLACE FUNCTION "public"."get_gare_details"("p_gare_id" "uuid") RETURNS TABLE("id" "uuid", "nom" "text", "type" VARCHAR(50), "services" "public"."service_type"[], "quais" "jsonb", "transports" "jsonb", "created_at" timestamp with time zone, "updated_at" timestamp with time zone)
|
||||
LANGUAGE "plpgsql" STABLE SECURITY DEFINER
|
||||
AS $$
|
||||
BEGIN
|
||||
RETURN QUERY
|
||||
SELECT
|
||||
g.id,
|
||||
g.nom,
|
||||
g.type,
|
||||
g.services,
|
||||
COALESCE(
|
||||
(SELECT jsonb_agg(jsonb_build_object('id', q.id, 'nom', q.nom, 'distance_metres', q.distance_metres))
|
||||
FROM public.gare_quais q WHERE q.gare_id = g.id),
|
||||
'[]'::jsonb
|
||||
) as quais,
|
||||
COALESCE(
|
||||
(SELECT jsonb_agg(jsonb_build_object('id', t.id, 'type', t.type, 'ligne', t.ligne))
|
||||
FROM public.gare_transports t WHERE t.gare_id = g.id),
|
||||
'[]'::jsonb
|
||||
) as transports,
|
||||
g.created_at,
|
||||
g.updated_at
|
||||
FROM public.gares g
|
||||
WHERE g.id = p_gare_id AND g.deleted_at IS NULL;
|
||||
END;
|
||||
$$;
|
||||
|
||||
CREATE OR REPLACE FUNCTION "public"."get_station_details"("p_station_id" "uuid") RETURNS TABLE("id" "uuid", "nom" "text", "type" VARCHAR(50), "services" "public"."service_type"[], "quais" "jsonb", "transports" "jsonb", "created_at" timestamp with time zone, "updated_at" timestamp with time zone)
|
||||
LANGUAGE "plpgsql" STABLE SECURITY DEFINER
|
||||
AS $$
|
||||
BEGIN
|
||||
RETURN QUERY
|
||||
SELECT
|
||||
s.id,
|
||||
s.nom,
|
||||
s.type,
|
||||
s.services,
|
||||
COALESCE(
|
||||
(SELECT jsonb_agg(jsonb_build_object('id', q.id, 'nom', q.nom, 'distance_metres', q.distance_metres))
|
||||
FROM public.station_quais q WHERE q.station_id = s.id),
|
||||
'[]'::jsonb
|
||||
) as quais,
|
||||
COALESCE(
|
||||
(SELECT jsonb_agg(jsonb_build_object('id', t.id, 'type', t.type, 'ligne', t.ligne))
|
||||
FROM public.station_transports t WHERE t.station_id = s.id),
|
||||
'[]'::jsonb
|
||||
) as transports,
|
||||
s.created_at,
|
||||
s.updated_at
|
||||
FROM public.stations s
|
||||
WHERE s.id = p_station_id AND s.deleted_at IS NULL;
|
||||
END;
|
||||
$$;
|
||||
|
||||
-- 5. Supprimer l'ancien ENUM qui ne sert plus
|
||||
DROP TYPE IF EXISTS "public"."station_type" CASCADE;
|
||||
Reference in new issue
Block a user