feat(csv-import): Implement SAVEPOINT handling for vitals baseline import
- Updated the CSV import logic to include SAVEPOINT management, allowing for better error handling during the vitals baseline import process. - Enhanced the SQL migration script to drop existing CHECK constraints related to the 'source' field, ensuring compatibility with the new universal CSV import. - Incremented DB_SCHEMA_VERSION to "20260409c" to reflect these changes and improve the import process reliability.
This commit is contained in:
1 parent
e60976e1cc
commit
5a0c71dd90
5 files changed
+52
-4
No files matched your search
@@ -1,5 +1,22 @@
|
||||
-- Universal-CSV-Import schreibt source = 'csv'; bisherige CHECK erlaubte das nicht → 500 beim Import.
|
||||
ALTER TABLE vitals_baseline DROP CONSTRAINT IF EXISTS vitals_baseline_source_check;
|
||||
-- Universal-CSV-Import setzt source = 'csv'. Alte CHECK-Constraints kennen das nicht.
|
||||
-- Namen können je nach PG-Version abweichen → alle passenden CHECK Constraints zu source droppen.
|
||||
DO $$
|
||||
DECLARE
|
||||
r RECORD;
|
||||
BEGIN
|
||||
FOR r IN
|
||||
SELECT c.conname
|
||||
FROM pg_constraint c
|
||||
JOIN pg_class t ON c.conrelid = t.oid
|
||||
WHERE t.relname = 'vitals_baseline'
|
||||
AND c.contype = 'c'
|
||||
AND pg_get_constraintdef(c.oid) ILIKE '%source%'
|
||||
AND pg_get_constraintdef(c.oid) ILIKE '%IN %'
|
||||
LOOP
|
||||
EXECUTE format('ALTER TABLE vitals_baseline DROP CONSTRAINT %I', r.conname);
|
||||
END LOOP;
|
||||
END $$;
|
||||
|
||||
ALTER TABLE vitals_baseline ADD CONSTRAINT vitals_baseline_source_check
|
||||
CHECK (source IN ('manual', 'apple_health', 'garmin', 'withings', 'csv'));
|
||||
|
||||
|
||||
Reference in new issue
Block a user