geovisio 2.11.0__py3-none-any.whl → 2.12.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- geovisio/__init__.py +30 -2
- geovisio/admin_cli/db.py +1 -1
- geovisio/db_migrations.py +2 -2
- geovisio/migrations/20221201_01_wpCGc-initial-schema.rollback.sql +9 -0
- geovisio/migrations/20221201_01_wpCGc-initial-schema.sql +71 -0
- geovisio/migrations/20221201_02_ZG8AR-camera-information.rollback.sql +5 -0
- geovisio/migrations/20221201_02_ZG8AR-camera-information.sql +10 -0
- geovisio/migrations/20221222_01_fsB6f-add-account.rollback.sql +7 -0
- geovisio/migrations/20221222_01_fsB6f-add-account.sql +33 -0
- geovisio/migrations/20230113_01_0co97-rm-metadata-duplicates.rollback.sql +5 -0
- geovisio/migrations/20230113_01_0co97-rm-metadata-duplicates.sql +5 -0
- geovisio/migrations/20230116_01_9PkjZ-add-oauth-provider.rollback.sql +12 -0
- geovisio/migrations/20230116_01_9PkjZ-add-oauth-provider.sql +10 -0
- geovisio/migrations/20230117_01_K71Pd-pictures-ts-index.rollback.sql +4 -0
- geovisio/migrations/20230117_01_K71Pd-pictures-ts-index.sql +4 -0
- geovisio/migrations/20230130_01_VRIv2-sequences-account.rollback.sql +5 -0
- geovisio/migrations/20230130_01_VRIv2-sequences-account.sql +25 -0
- geovisio/migrations/20230324_01_ba9WA-status.rollback.sql +35 -0
- geovisio/migrations/20230324_01_ba9WA-status.sql +11 -0
- geovisio/migrations/20230324_02_efgI6-picture-process.rollback.sql +20 -0
- geovisio/migrations/20230324_02_efgI6-picture-process.sql +44 -0
- geovisio/migrations/20230407_01_wofh1-computed-headings.rollback.sql +6 -0
- geovisio/migrations/20230407_01_wofh1-computed-headings.sql +6 -0
- geovisio/migrations/20230417_01_ZgLMY-add-exif-metadata-column-for-pictures.rollback.sql +4 -0
- geovisio/migrations/20230417_01_ZgLMY-add-exif-metadata-column-for-pictures.sql +4 -0
- geovisio/migrations/20230420_01_elaN3-remove-picture-and-sequence-file-paths.rollback.sql +5 -0
- geovisio/migrations/20230420_01_elaN3-remove-picture-and-sequence-file-paths.sql +5 -0
- geovisio/migrations/20230425_01_gYP77-pictures-edits-triggers.rollback.sql +5 -0
- geovisio/migrations/20230425_01_gYP77-pictures-edits-triggers.sql +64 -0
- geovisio/migrations/20230427_01_k5e5w-timestamps.rollback.sql +10 -0
- geovisio/migrations/20230427_01_k5e5w-timestamps.sql +19 -0
- geovisio/migrations/20230511_01_TdpKo-tokens.rollback.sql +7 -0
- geovisio/migrations/20230511_01_TdpKo-tokens.sql +34 -0
- geovisio/migrations/20230615_01_u7aRf-pic-delete-cascade.rollback.sql +10 -0
- geovisio/migrations/20230615_01_u7aRf-pic-delete-cascade.sql +12 -0
- geovisio/migrations/20230623_01_y1SiQ-pic-deletion-task.rollback.sql +39 -0
- geovisio/migrations/20230623_01_y1SiQ-pic-deletion-task.sql +36 -0
- geovisio/migrations/20230629_01_ZdB3i-compute-heading-0.sql +27 -0
- geovisio/migrations/20230711_01_JGSPB-inserted-at-index.rollback.sql +4 -0
- geovisio/migrations/20230711_01_JGSPB-inserted-at-index.sql +4 -0
- geovisio/migrations/20230720_01_EyQ0e-sequences-summary.rollback.sql +7 -0
- geovisio/migrations/20230720_01_EyQ0e-sequences-summary.sql +26 -0
- geovisio/migrations/20230803_01_aXusm-fix-sequence-computed.rollback.sql +4 -0
- geovisio/migrations/20230803_01_aXusm-fix-sequence-computed.sql +25 -0
- geovisio/migrations/20231018_01_4G3YE-pictures-exiv2.rollback.sql +165 -0
- geovisio/migrations/20231018_01_4G3YE-pictures-exiv2.sql +206 -0
- geovisio/migrations/20231103_01_ZVKEm-update-seq-on-pic-change.rollback.sql +7 -0
- geovisio/migrations/20231103_01_ZVKEm-update-seq-on-pic-change.sql +28 -0
- geovisio/migrations/20231110_01_3p070-jobs-error.rollback.sql +7 -0
- geovisio/migrations/20231110_01_3p070-jobs-error.sql +93 -0
- geovisio/migrations/20231121_01_v6oBF-more-specific-triggers.rollback.sql +36 -0
- geovisio/migrations/20231121_01_v6oBF-more-specific-triggers.sql +40 -0
- geovisio/migrations/20231121_02_1uZXT-deleted-tag.rollback.sql +19 -0
- geovisio/migrations/20231121_02_1uZXT-deleted-tag.sql +13 -0
- geovisio/migrations/20240115_01_FatLR-token-delete-cascade.rollback.sql +6 -0
- geovisio/migrations/20240115_01_FatLR-token-delete-cascade.sql +7 -0
- geovisio/migrations/20240220_01_9wZs0-sequence-current-sort.rollback.sql +6 -0
- geovisio/migrations/20240220_01_9wZs0-sequence-current-sort.sql +15 -0
- geovisio/migrations/20240223_01_LsMHB-remove-binary-fields.sql +80 -0
- geovisio/migrations/20240226_01_8iXl1-track-changes.rollback.sql +13 -0
- geovisio/migrations/20240226_01_8iXl1-track-changes.sql +123 -0
- geovisio/migrations/20240229_01_SgfQY-sequence-geom-multi-linestring.rollback.sql +67 -0
- geovisio/migrations/20240229_01_SgfQY-sequence-geom-multi-linestring.sql +101 -0
- geovisio/migrations/20240308_01_aF0Jb-migrate-sequence-geom-multi-linestring.sql +52 -0
- geovisio/migrations/20240409_01_jnhra-pictures-grid.rollback.sql +3 -0
- geovisio/migrations/20240409_01_jnhra-pictures-grid.sql +21 -0
- geovisio/migrations/20240416_01_FpyGs-pictures-stats-on-sequences.rollback.sql +7 -0
- geovisio/migrations/20240416_01_FpyGs-pictures-stats-on-sequences.sql +9 -0
- geovisio/migrations/20240416_02_A5KzC-fill-pictures-stats-on-sequences.rollback.sql +5 -0
- geovisio/migrations/20240416_02_A5KzC-fill-pictures-stats-on-sequences.sql +84 -0
- geovisio/migrations/20240507_01_eBfqZ-refresh-table.rollback.sql +5 -0
- geovisio/migrations/20240507_01_eBfqZ-refresh-table.sql +9 -0
- geovisio/migrations/20240507_02_dzVET-picture-grid-public.rollback.sql +21 -0
- geovisio/migrations/20240507_02_dzVET-picture-grid-public.sql +26 -0
- geovisio/migrations/20240514_01_IT7DD-picture-delete-cascade.rollback.sql +41 -0
- geovisio/migrations/20240514_01_IT7DD-picture-delete-cascade.sql +42 -0
- geovisio/migrations/20240611_01_jftHn-content-md5.rollback.sql +5 -0
- geovisio/migrations/20240611_01_jftHn-content-md5.sql +7 -0
- geovisio/migrations/20240612_01_yNcuE-upload-set.rollback.sql +6 -0
- geovisio/migrations/20240612_01_yNcuE-upload-set.sql +46 -0
- geovisio/migrations/20240617_01_tKtlx-md5-concurrent-index.rollback.sql +4 -0
- geovisio/migrations/20240617_01_tKtlx-md5-concurrent-index.sql +8 -0
- geovisio/migrations/20240625_01_XMZ24-fix-sequence-stat-on-pic-insertion.rollback.sql +30 -0
- geovisio/migrations/20240625_01_XMZ24-fix-sequence-stat-on-pic-insertion.sql +31 -0
- geovisio/migrations/20240708_01_Xn7IH-job-queue.rollback.sql +31 -0
- geovisio/migrations/20240708_01_Xn7IH-job-queue.sql +104 -0
- geovisio/migrations/20240715_01_Hca9V-upload-set-metadata.rollback.sql +4 -0
- geovisio/migrations/20240715_01_Hca9V-upload-set-metadata.sql +5 -0
- geovisio/migrations/20240723_01_ePGFe-upload-set-files.rollback.sql +7 -0
- geovisio/migrations/20240723_01_ePGFe-upload-set-files.sql +29 -0
- geovisio/migrations/20240729_01_HALjj-upload-set-sort.rollback.sql +18 -0
- geovisio/migrations/20240729_01_HALjj-upload-set-sort.sql +18 -0
- geovisio/migrations/20240730_01_2BaCy-improve-deletion-triggers.rollback.sql +34 -0
- geovisio/migrations/20240730_01_2BaCy-improve-deletion-triggers.sql +53 -0
- geovisio/migrations/20240730_02_aRymN-rejection-status.rollback.sql +10 -0
- geovisio/migrations/20240730_02_aRymN-rejection-status.sql +16 -0
- geovisio/migrations/20240801_01_DOqmf-reports.rollback.sql +11 -0
- geovisio/migrations/20240801_01_DOqmf-reports.sql +100 -0
- geovisio/migrations/20240801_01_uKqPo-remove-files-delete-cascade.rollback.sql +13 -0
- geovisio/migrations/20240801_01_uKqPo-remove-files-delete-cascade.sql +13 -0
- geovisio/migrations/20240813_01_T1XkO-sequences-geom-splits.rollback.sql +42 -0
- geovisio/migrations/20240813_01_T1XkO-sequences-geom-splits.sql +56 -0
- geovisio/migrations/20240820_01_aB2ZK-exclusion-zones.rollback.sql +6 -0
- geovisio/migrations/20240820_01_aB2ZK-exclusion-zones.sql +49 -0
- geovisio/migrations/20240902_01_MDqSj-user-agent.rollback.sql +5 -0
- geovisio/migrations/20240902_01_MDqSj-user-agent.sql +10 -0
- geovisio/migrations/20240904_01_gFjlV-files-rejection-msg.rollback.sql +4 -0
- geovisio/migrations/20240904_01_gFjlV-files-rejection-msg.sql +4 -0
- geovisio/migrations/20240905_01_C8F6U-conflicts.rollback.sql +13 -0
- geovisio/migrations/20240905_01_C8F6U-conflicts.sql +6 -0
- geovisio/migrations/20240905_01_E5Ki0-upload-set-delete.rollback.sql +5 -0
- geovisio/migrations/20240905_01_E5Ki0-upload-set-delete.sql +30 -0
- geovisio/migrations/20240909_01_Muc22-unique-grid-index.rollback.sql +4 -0
- geovisio/migrations/20240909_01_Muc22-unique-grid-index.sql +5 -0
- geovisio/migrations/20240912_01_dAALm-account-index.rollback.sql +4 -0
- geovisio/migrations/20240912_01_dAALm-account-index.sql +4 -0
- geovisio/migrations/20241004_01_d1zfe-pictures-grid-360.rollback.sql +22 -0
- geovisio/migrations/20241004_01_d1zfe-pictures-grid-360.sql +24 -0
- geovisio/migrations/20241011_01_e1j5C-pic-quality.rollback.sql +21 -0
- geovisio/migrations/20241011_01_e1j5C-pic-quality.sql +249 -0
- geovisio/migrations/20241017_01_GuOjF-pic-quality-update.rollback.sql +4 -0
- geovisio/migrations/20241017_01_GuOjF-pic-quality-update.sql +61 -0
- geovisio/migrations/20241017_01_RiFlm-pictures-to-delete.rollback.sql +43 -0
- geovisio/migrations/20241017_01_RiFlm-pictures-to-delete.sql +75 -0
- geovisio/migrations/20241104_01_yhRVu-rejection-details.rollback.sql +4 -0
- geovisio/migrations/20241104_01_yhRVu-rejection-details.sql +4 -0
- geovisio/migrations/20241128_01_ugthx-job-queue-args.rollback.sql +25 -0
- geovisio/migrations/20241128_01_ugthx-job-queue-args.sql +31 -0
- geovisio/migrations/20241224_01_xuN6n-delete-upload-set-on-last-picture-trg-statement.rollback.sql +27 -0
- geovisio/migrations/20241224_01_xuN6n-delete-upload-set-on-last-picture-trg-statement.sql +28 -0
- geovisio/migrations/20250102_01_EElhA-rm-cameras.rollback.sql +126 -0
- geovisio/migrations/20250102_01_EElhA-rm-cameras.sql +30 -0
- geovisio/migrations/20250107_01_EQN9v-tags-tables.rollback.sql +10 -0
- geovisio/migrations/20250107_01_EQN9v-tags-tables.sql +58 -0
- geovisio/migrations/20250109_01_4OOP4-pages.rollback.sql +4 -0
- geovisio/migrations/20250109_01_4OOP4-pages.sql +10 -0
- geovisio/migrations/20250114_01_ABaaL-collaborative-metadata-editing.rollback.sql +7 -0
- geovisio/migrations/20250114_01_ABaaL-collaborative-metadata-editing.sql +16 -0
- geovisio/migrations/20250123_01_Ececu-tos-acceptance.rollback.sql +5 -0
- geovisio/migrations/20250123_01_Ececu-tos-acceptance.sql +5 -0
- geovisio/migrations/20250206_01_PjrEL-annotation-semantics.rollback.sql +14 -0
- geovisio/migrations/20250206_01_PjrEL-annotation-semantics.sql +15 -0
- geovisio/migrations/20250306_01_58oju-semantics-views.rollback.sql +5 -0
- geovisio/migrations/20250306_01_58oju-semantics-views.sql +52 -0
- geovisio/migrations/20250318_01_pANl1-semantics-functions.rollback.sql +5 -0
- geovisio/migrations/20250318_01_pANl1-semantics-functions.sql +41 -0
- geovisio/migrations/20250331_01_kRKjo-store-detections-id.rollback.sql +7 -0
- geovisio/migrations/20250331_01_kRKjo-store-detections-id.sql +25 -0
- geovisio/migrations/20250424_01_RBGXC-semantics-indexes.rollback.sql +6 -0
- geovisio/migrations/20250424_01_RBGXC-semantics-indexes.sql +6 -0
- geovisio/migrations/20250502_01_ZNmkU-job-task-read-metadata.rollback.sql +24 -0
- geovisio/migrations/20250502_01_ZNmkU-job-task-read-metadata.sql +7 -0
- geovisio/migrations/20250509_01_kMatW-deactivate-upload-set-split-dedup.rollback.sql +12 -0
- geovisio/migrations/20250509_01_kMatW-deactivate-upload-set-split-dedup.sql +12 -0
- geovisio/migrations/20250509_01_s3hYk-semantic-delete-cascade.rollback.sql +11 -0
- geovisio/migrations/20250509_01_s3hYk-semantic-delete-cascade.sql +11 -0
- geovisio/migrations/20250513_01_8WkZC-upload-sets-default-config.rollback.sql +7 -0
- geovisio/migrations/20250513_01_8WkZC-upload-sets-default-config.sql +15 -0
- geovisio/migrations/20250523_01_b11eW-picture-update-index.rollback.sql +85 -0
- geovisio/migrations/20250523_01_b11eW-picture-update-index.sql +166 -0
- geovisio/migrations/20250523_02_5ZXXh-update-picture-updated-at.rollback.sql +4 -0
- geovisio/migrations/20250523_02_5ZXXh-update-picture-updated-at.sql +7 -0
- geovisio/migrations/20250624_01_SETp6-job-warnings.rollback.sql +4 -0
- geovisio/migrations/20250624_01_SETp6-job-warnings.sql +4 -0
- geovisio/migrations/20250701_01_kr371-upload-set-semantics.rollback.sql +6 -0
- geovisio/migrations/20250701_01_kr371-upload-set-semantics.sql +15 -0
- geovisio/migrations/20250703_01_p2WVV-sequence-upload-set-link.rollback.sql +4 -0
- geovisio/migrations/20250703_01_p2WVV-sequence-upload-set-link.sql +4 -0
- geovisio/migrations/20250703_02_q0s3D-sequence-upload-set-fill.rollback.sql +4 -0
- geovisio/migrations/20250703_02_q0s3D-sequence-upload-set-fill.sql +26 -0
- geovisio/migrations/20250716_01_f8tcJ-check-empty-annotation-late.rollback.sql +24 -0
- geovisio/migrations/20250716_01_f8tcJ-check-empty-annotation-late.sql +10 -0
- geovisio/migrations/20250728_01_2zgur-upload-set-relative-heading.rollback.sql +4 -0
- geovisio/migrations/20250728_01_2zgur-upload-set-relative-heading.sql +4 -0
- geovisio/migrations/20250825_01_nCgkN-file-deletion-after-delete-no-dup.rollback.sql +20 -0
- geovisio/migrations/20250825_01_nCgkN-file-deletion-after-delete-no-dup.sql +26 -0
- geovisio/migrations/20250902_01_k5UTq-visibility-status.rollback.sql +11 -0
- geovisio/migrations/20250902_01_k5UTq-visibility-status.sql +19 -0
- geovisio/migrations/20250904_01_3uVKX-visibility-functions.rollback.sql +20 -0
- geovisio/migrations/20250904_01_3uVKX-visibility-functions.sql +43 -0
- geovisio/migrations/20251110_01_bWEXo-report-visibility.rollback.sql +30 -0
- geovisio/migrations/20251110_01_bWEXo-report-visibility.sql +30 -0
- geovisio/migrations/20251124_01_0xdqi-page-updates.rollback.sql +6 -0
- geovisio/migrations/20251124_01_0xdqi-page-updates.sql +8 -0
- geovisio/migrations/20251127_01_S6Ci8-pictures-grid-visibility.rollback.sql +24 -0
- geovisio/migrations/20251127_01_S6Ci8-pictures-grid-visibility.sql +36 -0
- geovisio/migrations/20251202_01_Q3g59-pictures-grid-logged-only.rollback.sql +32 -0
- geovisio/migrations/20251202_01_Q3g59-pictures-grid-logged-only.sql +34 -0
- geovisio/templates/main.html +7 -58
- geovisio/templates/viewer.html +8 -15
- geovisio/translations/cy/LC_MESSAGES/messages.mo +0 -0
- geovisio/translations/cy/LC_MESSAGES/messages.po +839 -0
- geovisio/translations/en/LC_MESSAGES/messages.mo +0 -0
- geovisio/translations/en/LC_MESSAGES/messages.po +155 -149
- geovisio/translations/messages.pot +131 -150
- geovisio/utils/cql2.py +22 -17
- geovisio/utils/link.py +13 -3
- geovisio/utils/upload_set.py +42 -2
- geovisio/web/collections.py +80 -40
- geovisio/web/docs.py +1 -1
- geovisio/web/items.py +54 -4
- geovisio/web/upload_set.py +2 -3
- geovisio/web/users.py +1 -1
- {geovisio-2.11.0.dist-info → geovisio-2.12.0.dist-info}/METADATA +6 -26
- geovisio-2.12.0.dist-info/RECORD +305 -0
- geovisio-2.12.0.dist-info/entry_points.txt +3 -0
- geovisio-2.11.0.dist-info/RECORD +0 -117
- {geovisio-2.11.0.dist-info → geovisio-2.12.0.dist-info}/WHEEL +0 -0
- {geovisio-2.11.0.dist-info → geovisio-2.12.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
-- rm-cameras
|
|
2
|
+
-- depends: 20241128_01_ugthx-job-queue-args
|
|
3
|
+
|
|
4
|
+
-- Get rid of cameras table, infos are coming from Tag Reader
|
|
5
|
+
DROP TABLE cameras;
|
|
6
|
+
|
|
7
|
+
-- Replace trigger which updated GPS accuracy & Px density to only update Px density
|
|
8
|
+
DROP TRIGGER trg_pictures_hpixdens_gpsacc ON pictures;
|
|
9
|
+
DROP TRIGGER trg_pictures_hpixdens_gpsacc_upd ON pictures;
|
|
10
|
+
DROP FUNCTION pictures_hpixdens_gpsacc;
|
|
11
|
+
DROP FUNCTION gps_accuracy;
|
|
12
|
+
DROP FUNCTION get_float;
|
|
13
|
+
DROP FUNCTION missing_fov;
|
|
14
|
+
|
|
15
|
+
CREATE OR REPLACE FUNCTION pictures_hpixdens() RETURNS TRIGGER AS $$
|
|
16
|
+
BEGIN
|
|
17
|
+
NEW.h_pixel_density := h_pixel_density(NEW.metadata);
|
|
18
|
+
RETURN NEW;
|
|
19
|
+
END;
|
|
20
|
+
$$ LANGUAGE plpgsql;
|
|
21
|
+
|
|
22
|
+
CREATE TRIGGER trg_pictures_hpixdens
|
|
23
|
+
BEFORE INSERT ON pictures
|
|
24
|
+
FOR EACH ROW
|
|
25
|
+
EXECUTE FUNCTION pictures_hpixdens();
|
|
26
|
+
|
|
27
|
+
CREATE TRIGGER trg_pictures_hpixdens_upd
|
|
28
|
+
BEFORE UPDATE OF metadata, exif ON pictures
|
|
29
|
+
FOR EACH ROW
|
|
30
|
+
EXECUTE FUNCTION pictures_hpixdens();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- tags_tables
|
|
2
|
+
-- depends: 20241224_01_xuN6n-delete-upload-set-on-last-picture-trg-statement
|
|
3
|
+
|
|
4
|
+
DROP TABLE annotations_semantics_history;
|
|
5
|
+
DROP TABLE sequences_semantics_history;
|
|
6
|
+
DROP TABLE pictures_semantics_history;
|
|
7
|
+
DROP TABLE annotations_semantics;
|
|
8
|
+
DROP TABLE annotations;
|
|
9
|
+
DROP TABLE sequences_semantics;
|
|
10
|
+
DROP TABLE pictures_semantics;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
-- tags_tables
|
|
2
|
+
-- depends: 20241224_01_xuN6n-delete-upload-set-on-last-picture-trg-statement
|
|
3
|
+
|
|
4
|
+
CREATE TABLE annotations (
|
|
5
|
+
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
6
|
+
picture_id UUID NOT NULL REFERENCES pictures(id) ON DELETE CASCADE,
|
|
7
|
+
shape polygon NOT NULL -- postgres geometry, not postgis.
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
CREATE INDEX annotations_picture_id_idx ON annotations(picture_id);
|
|
11
|
+
|
|
12
|
+
CREATE TABLE annotations_semantics (
|
|
13
|
+
annotation_id UUID NOT NULL REFERENCES annotations(id) ON DELETE CASCADE,
|
|
14
|
+
key TEXT NOT NULL,
|
|
15
|
+
value TEXT NOT NULL,
|
|
16
|
+
PRIMARY KEY (annotation_id, key, value)
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
CREATE INDEX annotations_semantics_annotation_id_idx ON annotations_semantics(annotation_id);
|
|
20
|
+
|
|
21
|
+
CREATE TABLE sequences_semantics (
|
|
22
|
+
sequence_id UUID NOT NULL References sequences(id) ON DELETE CASCADE,
|
|
23
|
+
key TEXT NOT NULL,
|
|
24
|
+
value TEXT NOT NULL,
|
|
25
|
+
PRIMARY KEY (sequence_id, key, value)
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
CREATE INDEX sequences_semantics_sequence_id_idx ON sequences_semantics(sequence_id);
|
|
29
|
+
|
|
30
|
+
CREATE TABLE pictures_semantics (
|
|
31
|
+
picture_id UUID NOT NULL References pictures(id) ON DELETE CASCADE,
|
|
32
|
+
key TEXT NOT NULL,
|
|
33
|
+
value TEXT NOT NULL,
|
|
34
|
+
PRIMARY KEY (picture_id, key, value)
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
CREATE INDEX pictures_semantics_picture_id_idx ON pictures_semantics(picture_id);
|
|
38
|
+
|
|
39
|
+
-- history tables, one associated to each table
|
|
40
|
+
CREATE TABLE annotations_semantics_history (
|
|
41
|
+
annotation_id UUID NOT NULL REFERENCES annotations(id),
|
|
42
|
+
account_id UUID REFERENCES accounts(id),
|
|
43
|
+
ts TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
44
|
+
updates JSONB NOT NULL
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
CREATE TABLE sequences_semantics_history (
|
|
48
|
+
sequence_id UUID NOT NULL References sequences(id),
|
|
49
|
+
account_id UUID REFERENCES accounts(id),
|
|
50
|
+
ts TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
51
|
+
updates JSONB NOT NULL
|
|
52
|
+
);
|
|
53
|
+
CREATE TABLE pictures_semantics_history (
|
|
54
|
+
picture_id UUID NOT NULL References pictures(id),
|
|
55
|
+
account_id UUID REFERENCES accounts(id),
|
|
56
|
+
ts TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
57
|
+
updates JSONB NOT NULL
|
|
58
|
+
);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
-- pages
|
|
2
|
+
-- depends: 20241224_01_xuN6n-delete-upload-set-on-last-picture-trg-statement 20250102_01_EElhA-rm-cameras
|
|
3
|
+
|
|
4
|
+
-- Custom HTML pages
|
|
5
|
+
CREATE TABLE pages(
|
|
6
|
+
name VARCHAR(50) NOT NULL,
|
|
7
|
+
lang VARCHAR(10) NOT NULL,
|
|
8
|
+
content TEXT NOT NULL,
|
|
9
|
+
PRIMARY KEY (name, lang)
|
|
10
|
+
);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
-- collaborative_metadata_editing
|
|
2
|
+
-- depends: 20250102_01_EElhA-rm-cameras 20250107_01_EQN9v-tags-tables
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
ALTER TABLE accounts ADD COLUMN collaborative_metadata BOOLEAN;
|
|
6
|
+
COMMENT ON COLUMN accounts.collaborative_metadata IS 'If true, all sequences will be, by default, editable by all users';
|
|
7
|
+
|
|
8
|
+
CREATE TABLE configurations (
|
|
9
|
+
onerow_id bool PRIMARY KEY DEFAULT true, -- add a boolean primary key, always true, making it impossible to have more than one row in this configuration table
|
|
10
|
+
collaborative_metadata BOOLEAN, -- Note: it's important for the configurations not to have a default value, to know if it was set by the admin or not
|
|
11
|
+
|
|
12
|
+
CONSTRAINT onerow_uni CHECK (onerow_id)
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
-- Add one empty value for the configuration
|
|
16
|
+
INSERT INTO configurations (collaborative_metadata) VALUES (null);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
-- tos_acceptance
|
|
2
|
+
-- depends: 20250109_01_4OOP4-pages 20250114_01_ABaaL-collaborative-metadata-editing
|
|
3
|
+
|
|
4
|
+
ALTER TABLE accounts ADD COLUMN tos_accepted_at TIMESTAMP WITH TIME ZONE;
|
|
5
|
+
ALTER TABLE accounts ADD COLUMN tos_accepted BOOLEAN GENERATED ALWAYS AS (tos_accepted_at IS NOT NULL) STORED;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
-- annotation_semantics
|
|
2
|
+
-- depends: 20250109_01_4OOP4-pages 20250114_01_ABaaL-collaborative-metadata-editing
|
|
3
|
+
|
|
4
|
+
-- Annotation semantics will be stored in the pictures_semantics table (just with an additional annotation_id in the json)
|
|
5
|
+
-- This way if an annotation is deleted, we keep the history easily
|
|
6
|
+
CREATE TABLE annotations_semantics_history (
|
|
7
|
+
annotation_id UUID NOT NULL REFERENCES annotations(id),
|
|
8
|
+
account_id UUID REFERENCES accounts(id),
|
|
9
|
+
ts TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
10
|
+
updates JSONB NOT NULL
|
|
11
|
+
);
|
|
12
|
+
-- add indexes on history tables
|
|
13
|
+
DROP INDEX pictures_semantics_history_picture_id_idx;
|
|
14
|
+
DROP INDEX sequences_semantics_history_sequence_id_idx;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
-- annotation_semantics
|
|
2
|
+
-- depends: 20250109_01_4OOP4-pages 20250114_01_ABaaL-collaborative-metadata-editing
|
|
3
|
+
|
|
4
|
+
-- Annotation semantics will be stored in the pictures_semantics table (just with an additional annotation_id in the json)
|
|
5
|
+
-- This way if an annotation is deleted, we keep the history easily
|
|
6
|
+
DROP TABLE annotations_semantics_history;
|
|
7
|
+
|
|
8
|
+
-- psycopg doesn't support polygon natively, and polygon might not be enough in the futur, so we use directly jsonb here
|
|
9
|
+
ALTER TABLE annotations ALTER COLUMN shape TYPE JSONB USING NULL;
|
|
10
|
+
|
|
11
|
+
-- add indexes on history tables
|
|
12
|
+
CREATE INDEX pictures_semantics_history_picture_id_idx ON pictures_semantics_history(picture_id);
|
|
13
|
+
CREATE INDEX sequences_semantics_history_sequence_id_idx ON sequences_semantics_history(sequence_id);
|
|
14
|
+
|
|
15
|
+
-- ALTER TABLE pictures_semantics_history ADD COLUMN annotation UUID REFERENCES annotations(id);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
-- semantics_views
|
|
2
|
+
-- depends: 20250123_01_Ececu-tos-acceptance 20250206_01_PjrEL-annotation-semantics
|
|
3
|
+
|
|
4
|
+
CREATE VIEW sequences_semantics_aggregated AS (
|
|
5
|
+
SELECT sequence_id, json_agg(json_strip_nulls(json_build_object(
|
|
6
|
+
'key', key,
|
|
7
|
+
'value', value
|
|
8
|
+
)) ORDER BY key, value) AS semantics
|
|
9
|
+
FROM sequences_semantics
|
|
10
|
+
GROUP BY sequence_id
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
-- This view groups all semantics associated to a picture, so its tags and its annotations tags
|
|
14
|
+
CREATE VIEW pictures_semantics_aggregated AS (
|
|
15
|
+
WITH annotation_semantics_as_json AS (
|
|
16
|
+
SELECT picture_id,
|
|
17
|
+
shape,
|
|
18
|
+
id,
|
|
19
|
+
json_agg(json_strip_nulls(json_build_object(
|
|
20
|
+
'key', key,
|
|
21
|
+
'value', value
|
|
22
|
+
)) ORDER BY key, value) AS semantics
|
|
23
|
+
FROM annotations a
|
|
24
|
+
LEFT JOIN annotations_semantics s on a.id = s.annotation_id
|
|
25
|
+
GROUP BY a.id
|
|
26
|
+
)
|
|
27
|
+
, aggregated_annotations AS (
|
|
28
|
+
select pictures.id as picture_id,
|
|
29
|
+
json_agg(json_strip_nulls(json_build_object(
|
|
30
|
+
'id', a.id,
|
|
31
|
+
'shape', a.shape,
|
|
32
|
+
'semantics', a.semantics))) AS annotations
|
|
33
|
+
FROM pictures
|
|
34
|
+
LEFT JOIN annotation_semantics_as_json a ON a.picture_id = pictures.id
|
|
35
|
+
GROUP by pictures.id
|
|
36
|
+
)
|
|
37
|
+
, pics_semantics AS (
|
|
38
|
+
select id,
|
|
39
|
+
json_agg(json_strip_nulls(json_build_object(
|
|
40
|
+
'key', key,
|
|
41
|
+
'value', value
|
|
42
|
+
)) ORDER BY key, value) AS semantics
|
|
43
|
+
FROM pictures
|
|
44
|
+
LEFT JOIN pictures_semantics ON pictures.id = pictures_semantics.picture_id
|
|
45
|
+
GROUP by pictures.id
|
|
46
|
+
)
|
|
47
|
+
select a.picture_id,
|
|
48
|
+
a.annotations,
|
|
49
|
+
p.semantics
|
|
50
|
+
FROM pics_semantics p
|
|
51
|
+
LEFT JOIN aggregated_annotations a ON a.picture_id = p.id
|
|
52
|
+
);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
-- semantics_functions
|
|
2
|
+
-- depends: 20250306_01_58oju-semantics-views
|
|
3
|
+
|
|
4
|
+
CREATE OR REPLACE FUNCTION get_picture_annotations(pic_id UUID)
|
|
5
|
+
RETURNS JSONB AS
|
|
6
|
+
$$
|
|
7
|
+
SELECT
|
|
8
|
+
json_agg(json_strip_nulls(json_build_object(
|
|
9
|
+
'id', a.id,
|
|
10
|
+
'shape', a.shape,
|
|
11
|
+
'semantics', a.semantics
|
|
12
|
+
))) AS annotations
|
|
13
|
+
FROM (
|
|
14
|
+
SELECT picture_id,
|
|
15
|
+
shape,
|
|
16
|
+
id,
|
|
17
|
+
json_agg(json_strip_nulls(json_build_object(
|
|
18
|
+
'key', key,
|
|
19
|
+
'value', value
|
|
20
|
+
)) ORDER BY key, value) AS semantics
|
|
21
|
+
FROM annotations a
|
|
22
|
+
LEFT JOIN annotations_semantics s ON a.id = s.annotation_id
|
|
23
|
+
WHERE a.picture_id = pic_id
|
|
24
|
+
GROUP BY a.id
|
|
25
|
+
) a
|
|
26
|
+
GROUP BY picture_id;
|
|
27
|
+
$$ LANGUAGE sql STABLE PARALLEL SAFE;
|
|
28
|
+
|
|
29
|
+
CREATE OR REPLACE FUNCTION get_picture_semantics(pic_id UUID)
|
|
30
|
+
RETURNS JSONB AS
|
|
31
|
+
$$
|
|
32
|
+
SELECT
|
|
33
|
+
json_agg(json_strip_nulls(json_build_object(
|
|
34
|
+
'key', key,
|
|
35
|
+
'value', value
|
|
36
|
+
)) ORDER BY key, value) AS semantics
|
|
37
|
+
FROM pictures
|
|
38
|
+
LEFT JOIN pictures_semantics ON pictures.id = pictures_semantics.picture_id
|
|
39
|
+
where pictures.id = pic_id
|
|
40
|
+
GROUP by pictures.id
|
|
41
|
+
$$ LANGUAGE sql STABLE PARALLEL SAFE;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
-- store_detections
|
|
2
|
+
-- depends: 20250318_01_pANl1-semantics-functions
|
|
3
|
+
|
|
4
|
+
ALTER TABLE pictures ADD column blurring_id VARCHAR;
|
|
5
|
+
|
|
6
|
+
DROP FUNCTION IF EXISTS delete_empty_annotations CASCADE;
|
|
7
|
+
CREATE FUNCTION delete_empty_annotations() RETURNS trigger AS $$
|
|
8
|
+
BEGIN
|
|
9
|
+
-- Delete annotations where no remaining semantics exist
|
|
10
|
+
DELETE FROM annotations a
|
|
11
|
+
WHERE a.id IN (
|
|
12
|
+
SELECT DISTINCT(deleted_as.annotation_id)
|
|
13
|
+
FROM deleted_annotations_semantics deleted_as
|
|
14
|
+
LEFT JOIN annotations_semantics ON deleted_as.annotation_id = annotations_semantics.annotation_id
|
|
15
|
+
WHERE annotations_semantics.annotation_id IS NULL
|
|
16
|
+
);
|
|
17
|
+
RETURN NULL;
|
|
18
|
+
END $$ LANGUAGE plpgsql;
|
|
19
|
+
|
|
20
|
+
-- trigger to delete annotation is there is no semantics tags
|
|
21
|
+
CREATE TRIGGER delete_empty_annotation_trg
|
|
22
|
+
AFTER DELETE ON annotations_semantics
|
|
23
|
+
REFERENCING OLD TABLE AS deleted_annotations_semantics
|
|
24
|
+
FOR EACH STATEMENT
|
|
25
|
+
EXECUTE FUNCTION delete_empty_annotations();
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
-- semantics_indexes
|
|
2
|
+
-- depends: 20250331_01_kRKjo-store-detections-id
|
|
3
|
+
|
|
4
|
+
CREATE INDEX pictures_semantics_keyval_idx ON pictures_semantics(key text_pattern_ops, value text_pattern_ops);
|
|
5
|
+
CREATE INDEX sequences_semantics_keyval_idx ON sequences_semantics(key text_pattern_ops, value text_pattern_ops);
|
|
6
|
+
CREATE INDEX annotations_semantics_keyval_idx ON annotations_semantics(key text_pattern_ops, value text_pattern_ops);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
-- job_task_read_metadata
|
|
2
|
+
-- depends: 20250424_01_RBGXC-semantics-indexes
|
|
3
|
+
|
|
4
|
+
delete from job_history where job_task = 'read_metadata';
|
|
5
|
+
|
|
6
|
+
CREATE TYPE job_type_new AS ENUM (
|
|
7
|
+
'prepare', -- picture needs to be prepared to be published
|
|
8
|
+
'delete', -- picture needs to be deleted
|
|
9
|
+
'dispatch', -- upload set needs to be dispatched into several collections
|
|
10
|
+
'finalize' -- finalize a collection
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
alter table job_queue ALTER COLUMN task TYPE job_type_new USING task::text::job_type_new;
|
|
14
|
+
alter table job_history ALTER COLUMN job_task DROP DEFAULT;
|
|
15
|
+
alter table job_history ALTER COLUMN job_task TYPE job_type_new USING job_task::text::job_type_new;
|
|
16
|
+
alter table job_history ALTER COLUMN job_task SET DEFAULT 'prepare';
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
DROP TYPE job_type;
|
|
20
|
+
ALTER TYPE job_type_new RENAME TO job_type;
|
|
21
|
+
|
|
22
|
+
CREATE VIEW pictures_to_process AS (
|
|
23
|
+
SELECT picture_id, ts, task, nb_errors FROM job_queue WHERE task IN ('prepare', 'delete')
|
|
24
|
+
);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
-- deactivate_upload_set_split_dedup
|
|
2
|
+
-- depends: 20250424_01_RBGXC-semantics-indexes
|
|
3
|
+
|
|
4
|
+
ALTER TABLE upload_sets DROP COLUMN no_deduplication;
|
|
5
|
+
ALTER TABLE upload_sets DROP COLUMN no_split;
|
|
6
|
+
|
|
7
|
+
-- drop default on the dispatch param, to be able to handle those at code level
|
|
8
|
+
alter table upload_sets ALTER COLUMN split_time SET DEFAULT INTERVAL '1 minute';
|
|
9
|
+
alter table upload_sets ALTER COLUMN split_distance SET DEFAULT 100;
|
|
10
|
+
alter table upload_sets ALTER COLUMN duplicate_distance SET DEFAULT 1;
|
|
11
|
+
alter table upload_sets ALTER COLUMN duplicate_rotation SET DEFAULT 30;
|
|
12
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
-- deactivate_upload_set_split_dedup
|
|
2
|
+
-- depends: 20250424_01_RBGXC-semantics-indexes
|
|
3
|
+
|
|
4
|
+
ALTER TABLE upload_sets ADD COLUMN no_deduplication BOOLEAN;
|
|
5
|
+
ALTER TABLE upload_sets ADD COLUMN no_split BOOLEAN;
|
|
6
|
+
|
|
7
|
+
-- drop default on the dispatch param, to be able to handle those at code level
|
|
8
|
+
alter table upload_sets ALTER COLUMN split_time DROP DEFAULT;
|
|
9
|
+
alter table upload_sets ALTER COLUMN split_distance DROP DEFAULT;
|
|
10
|
+
alter table upload_sets ALTER COLUMN duplicate_distance DROP DEFAULT;
|
|
11
|
+
alter table upload_sets ALTER COLUMN duplicate_rotation DROP DEFAULT;
|
|
12
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
-- semantic_delete_cascade
|
|
2
|
+
-- depends: 20250424_01_RBGXC-semantics-indexes
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
ALTER TABLE pictures_semantics_history
|
|
6
|
+
DROP CONSTRAINT pictures_semantics_history_picture_id_fkey ,
|
|
7
|
+
ADD CONSTRAINT pictures_semantics_history_picture_id_fkey FOREIGN KEY (picture_id) REFERENCES pictures(id);
|
|
8
|
+
|
|
9
|
+
ALTER TABLE sequences_semantics_history
|
|
10
|
+
DROP CONSTRAINT sequences_semantics_history_sequence_id_fkey ,
|
|
11
|
+
ADD CONSTRAINT sequences_semantics_history_sequence_id_fkey FOREIGN KEY (sequence_id) REFERENCES sequences(id);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
-- semantic_delete_cascade
|
|
2
|
+
-- depends: 20250424_01_RBGXC-semantics-indexes
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
ALTER TABLE pictures_semantics_history
|
|
6
|
+
DROP CONSTRAINT pictures_semantics_history_picture_id_fkey ,
|
|
7
|
+
ADD CONSTRAINT pictures_semantics_history_picture_id_fkey FOREIGN KEY (picture_id) REFERENCES pictures(id) ON DELETE CASCADE;
|
|
8
|
+
|
|
9
|
+
ALTER TABLE sequences_semantics_history
|
|
10
|
+
DROP CONSTRAINT sequences_semantics_history_sequence_id_fkey ,
|
|
11
|
+
ADD CONSTRAINT sequences_semantics_history_sequence_id_fkey FOREIGN KEY (sequence_id) REFERENCES sequences(id) ON DELETE CASCADE;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
-- upload_sets_default_config
|
|
2
|
+
-- depends: 20250502_01_ZNmkU-job-task-read-metadata 20250509_01_kMatW-deactivate-upload-set-split-dedup 20250509_01_s3hYk-semantic-delete-cascade
|
|
3
|
+
ALTER TABLE configurations
|
|
4
|
+
DROP COLUMN default_split_distance,
|
|
5
|
+
DROP COLUMN default_split_time,
|
|
6
|
+
DROP COLUMN default_duplicate_distance,
|
|
7
|
+
DROP COLUMN default_duplicate_rotation;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
-- upload_sets_default_config
|
|
2
|
+
-- depends: 20250502_01_ZNmkU-job-task-read-metadata 20250509_01_kMatW-deactivate-upload-set-split-dedup 20250509_01_s3hYk-semantic-delete-cascade
|
|
3
|
+
ALTER TABLE configurations
|
|
4
|
+
ADD COLUMN default_split_distance INT DEFAULT 100,
|
|
5
|
+
ADD COLUMN default_split_time INTERVAL DEFAULT INTERVAL '5 minute',
|
|
6
|
+
ADD COLUMN default_duplicate_distance real DEFAULT 1,
|
|
7
|
+
ADD COLUMN default_duplicate_rotation INT DEFAULT 60;
|
|
8
|
+
|
|
9
|
+
COMMENT ON COLUMN configurations.default_split_distance IS 'Maximum distance between two pictures to be considered in the same sequence (in meters).';
|
|
10
|
+
|
|
11
|
+
COMMENT ON COLUMN configurations.default_split_time IS 'Maximum time interval between two pictures to be considered in the same sequence.';
|
|
12
|
+
|
|
13
|
+
COMMENT ON COLUMN configurations.default_duplicate_distance IS 'Maximum distance between two pictures to be considered as duplicates (in meters).';
|
|
14
|
+
|
|
15
|
+
COMMENT ON COLUMN configurations.default_duplicate_rotation IS 'Maximum angle of rotation for two too-close-pictures to be considered as duplicates (in degrees).';
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
-- picture_update_index
|
|
2
|
+
-- depends: 20250513_01_8WkZC-upload-sets-default-config
|
|
3
|
+
|
|
4
|
+
ALTER TABLE pictures DROP COLUMN updated_at CASCADE;
|
|
5
|
+
|
|
6
|
+
DROP TRIGGER pictures_updated_at_on_semantic_insert_trg ON pictures_semantics;
|
|
7
|
+
DROP TRIGGER pictures_updated_at_on_semantic_change_trg ON pictures_semantics;
|
|
8
|
+
DROP TRIGGER pictures_updated_at_on_semantic_delete_trg ON pictures_semantics;
|
|
9
|
+
DROP TRIGGER pictures_updated_at_on_annotation_insert_trg ON annotations_semantics;
|
|
10
|
+
DROP TRIGGER pictures_updated_at_on_annotation_change_trg ON annotations_semantics;
|
|
11
|
+
DROP TRIGGER a_pictures_updated_at_on_annotation_delete_trg ON annotations_semantics;
|
|
12
|
+
|
|
13
|
+
DROP TRIGGER pictures_updated_at_on_picture_change_trg ON pictures_changes;
|
|
14
|
+
|
|
15
|
+
DROP FUNCTION update_pictures_updated_at_on_pictures_change;
|
|
16
|
+
DROP FUNCTION update_pictures_updated_at_on_semantics;
|
|
17
|
+
DROP FUNCTION update_pictures_updated_at_on_annotation;
|
|
18
|
+
|
|
19
|
+
-- put back old behavior for sequences's updated_at update
|
|
20
|
+
|
|
21
|
+
DROP TRIGGER IF EXISTS pictures_updates_on_sequences_trg ON pictures CASCADE;
|
|
22
|
+
DROP TRIGGER IF EXISTS pictures_deletes_on_sequences_trg ON pictures CASCADE;
|
|
23
|
+
|
|
24
|
+
DROP FUNCTION IF EXISTS pictures_updates_on_sequences;
|
|
25
|
+
DROP FUNCTION pictures_deletions_updated_at_on_sequences;
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
CREATE FUNCTION pictures_updates_on_sequences() RETURNS trigger AS $$
|
|
29
|
+
BEGIN
|
|
30
|
+
UPDATE sequences
|
|
31
|
+
SET updated_at = current_timestamp
|
|
32
|
+
WHERE id IN (
|
|
33
|
+
SELECT DISTINCT sp.seq_id
|
|
34
|
+
FROM pictures_after p
|
|
35
|
+
JOIN sequences_pictures sp ON sp.pic_id = p.id
|
|
36
|
+
);
|
|
37
|
+
RETURN NULL;
|
|
38
|
+
END $$ LANGUAGE plpgsql;
|
|
39
|
+
|
|
40
|
+
CREATE TRIGGER pictures_updates_on_sequences_trg
|
|
41
|
+
AFTER UPDATE ON pictures
|
|
42
|
+
REFERENCING NEW TABLE AS pictures_after
|
|
43
|
+
FOR EACH STATEMENT
|
|
44
|
+
EXECUTE FUNCTION pictures_updates_on_sequences();
|
|
45
|
+
|
|
46
|
+
CREATE TRIGGER pictures_deletes_on_sequences_trg
|
|
47
|
+
AFTER DELETE ON pictures
|
|
48
|
+
REFERENCING OLD TABLE AS pictures_after
|
|
49
|
+
FOR EACH STATEMENT
|
|
50
|
+
EXECUTE FUNCTION pictures_updates_on_sequences();
|
|
51
|
+
|
|
52
|
+
DROP FUNCTION picture_modification_history CASCADE;
|
|
53
|
+
CREATE FUNCTION picture_modification_history() RETURNS TRIGGER AS
|
|
54
|
+
$BODY$
|
|
55
|
+
DECLARE
|
|
56
|
+
previous_value_changed JSONB;
|
|
57
|
+
parent_sequence_change_id UUID;
|
|
58
|
+
BEGIN
|
|
59
|
+
previous_value_changed := jsonb_diff(to_jsonb(OLD), to_jsonb(NEW)) - 'last_account_to_edit' ;
|
|
60
|
+
|
|
61
|
+
-- if there is a sequence modified on the same transaction, we link the picture change to the sequence change.
|
|
62
|
+
IF EXISTS (
|
|
63
|
+
SELECT 1
|
|
64
|
+
FROM information_schema.tables
|
|
65
|
+
WHERE table_type = 'LOCAL TEMPORARY'
|
|
66
|
+
AND table_name = 'sequence_current_change'
|
|
67
|
+
|
|
68
|
+
) THEN
|
|
69
|
+
SELECT change_id FROM sequence_current_change INTO parent_sequence_change_id;
|
|
70
|
+
END IF;
|
|
71
|
+
|
|
72
|
+
INSERT INTO pictures_changes (picture_id, account_id, previous_value_changed, sequences_changes_id)
|
|
73
|
+
VALUES (NEW.id, NEW.last_account_to_edit, previous_value_changed, parent_sequence_change_id);
|
|
74
|
+
|
|
75
|
+
RETURN NULL;
|
|
76
|
+
END;
|
|
77
|
+
$BODY$
|
|
78
|
+
language plpgsql;
|
|
79
|
+
|
|
80
|
+
CREATE TRIGGER picture_modification_history_trg
|
|
81
|
+
AFTER UPDATE OF
|
|
82
|
+
last_account_to_edit
|
|
83
|
+
ON pictures
|
|
84
|
+
FOR EACH ROW
|
|
85
|
+
EXECUTE PROCEDURE picture_modification_history();
|