fix: a module of the tfvars store says whether it discovers its configurator, as configuratorDiscovery.
Release / release (push) Successful in 25s

This commit is contained in:
slawek committed 2026-11-07 02:03:17 +01:00
1 parent 6d365cf529
commit 959d578910
8 files changed
+86 -24

No files matched your search

+36 -11
View File
@@ -4,12 +4,24 @@
-- again.
CREATE TABLE IF NOT EXISTS tf_modules (
name text PRIMARY KEY CHECK (name ~ '^[a-z][a-z0-9-]*$'),
root text NOT NULL CHECK (root <> ''),
description text NOT NULL DEFAULT '',
configurator_url text
name text PRIMARY KEY CHECK (name ~ '^[a-z][a-z0-9-]*$'),
root text NOT NULL CHECK (root <> ''),
description text NOT NULL DEFAULT '',
configurator_url text,
configurator_discovery boolean NOT NULL DEFAULT false
);
-- A module registered before configurator_discovery keeps finding its configurator.
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM information_schema.columns
WHERE table_schema = current_schema() AND table_name = 'tf_modules' AND column_name = 'configurator_discovery') THEN
ALTER TABLE tf_modules ADD COLUMN configurator_discovery boolean NOT NULL DEFAULT true;
ALTER TABLE tf_modules ALTER COLUMN configurator_discovery SET DEFAULT false;
END IF;
END
$$;
CREATE TABLE IF NOT EXISTS tf_instances (
module text NOT NULL REFERENCES tf_modules (name),
name text NOT NULL CHECK (name ~ '^[a-z][a-z0-9-]*$'),
@@ -51,23 +63,36 @@ WHERE NOT EXISTS (SELECT 1 FROM tf_variable_revisions r WHERE r.module = f.modul
GROUP BY f.module, f.instance
ON CONFLICT DO NOTHING;
-- The modules, by name.
-- The modules, by name; its columns are those of the table, so a table of other columns replaces it.
DO $$
BEGIN
IF EXISTS (SELECT 1 FROM pg_proc p JOIN pg_namespace n ON n.oid = p.pronamespace
WHERE n.nspname = current_schema() AND p.proname = 'tf_modules_list'
AND NOT 'configurator_discovery' = ANY (coalesce(p.proargnames, '{}'))) THEN
DROP FUNCTION tf_modules_list();
END IF;
END
$$;
CREATE OR REPLACE FUNCTION tf_modules_list()
RETURNS TABLE (name text, root text, description text, configurator_url text)
RETURNS TABLE (name text, root text, description text, configurator_url text, configurator_discovery boolean)
LANGUAGE sql STABLE
SET search_path FROM CURRENT
AS $$
SELECT m.name, m.root, m.description, m.configurator_url FROM tf_modules m ORDER BY m.name
SELECT m.name, m.root, m.description, m.configurator_url, m.configurator_discovery FROM tf_modules m ORDER BY m.name
$$;
DROP PROCEDURE IF EXISTS tf_module_put(text, text, text, text);
-- Creates a module, or changes the one of that name.
CREATE OR REPLACE PROCEDURE tf_module_put(module_name text, module_root text, module_description text, module_configurator_url text)
CREATE OR REPLACE PROCEDURE tf_module_put(module_name text, module_root text, module_description text, module_configurator_url text, module_configurator_discovery boolean)
LANGUAGE sql
SET search_path FROM CURRENT
AS $$
INSERT INTO tf_modules (name, root, description, configurator_url)
VALUES (module_name, module_root, module_description, module_configurator_url)
ON CONFLICT (name) DO UPDATE SET root = excluded.root, description = excluded.description, configurator_url = excluded.configurator_url
INSERT INTO tf_modules (name, root, description, configurator_url, configurator_discovery)
VALUES (module_name, module_root, module_description, module_configurator_url, module_configurator_discovery)
ON CONFLICT (name) DO UPDATE SET root = excluded.root, description = excluded.description,
configurator_url = excluded.configurator_url, configurator_discovery = excluded.configurator_discovery
$$;
-- Deletes a module; the foreign key of tf_instances refuses it while the module has instances.