-- Seed resources for tables, modules and forms
INSERT INTO resources (resource_type_id, tenant_id, branch_id, name, description)
SELECT (SELECT id FROM resource_types WHERE name='table'), NULL, NULL, table_name, NULL
FROM information_schema.tables
WHERE table_schema='public'
ON CONFLICT DO NOTHING;

INSERT INTO resources (resource_type_id, tenant_id, branch_id, name, description)
SELECT (SELECT id FROM resource_types WHERE name='module'), tenant_id, branch_id, name, description
FROM ui_modals
ON CONFLICT DO NOTHING;

INSERT INTO resources (resource_type_id, tenant_id, branch_id, name, description)
SELECT (SELECT id FROM resource_types WHERE name='form'), tenant_id, branch_id, name, description
FROM forms
ON CONFLICT DO NOTHING;
