File: /volume1/@appstore/SynologyPhotos/etc/sql/118.sql
CREATE OR REPLACE FUNCTION public.create_person_migration_migration_tables_func()
RETURNS void
LANGUAGE plpgsql
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER
COST 1
AS $$
DECLARE
production_tables CONSTANT TEXT[] := ARRAY['face', 'person_group', 'cluster', 'person'];
table_name TEXT;
BEGIN
FOR table_name IN SELECT unnest(production_tables) LOOP
EXECUTE format('CREATE TABLE IF NOT EXISTS %s_migration (LIKE %s INCLUDING ALL)', table_name, table_name);
EXECUTE format('TRUNCATE %s_migration CASCADE', table_name);
END LOOP;
PERFORM public.redefine_migration_constraint_func(production_tables);
PERFORM public.create_production_index_mapping_func(production_tables);
DROP TRIGGER IF EXISTS face_update_unit_version_trigger ON public.face_migration CASCADE;
CREATE TRIGGER face_update_unit_version_trigger
AFTER UPDATE
ON public.face_migration
FOR EACH ROW
EXECUTE PROCEDURE public.face_update_unit_version_func();
END
$$;