Commit Graph

118 Commits

Author SHA1 Message Date
D. Berge
0c6567d8f8 Add database upgrade file 11 2022-02-27 19:56:12 +01:00
D. Berge
0ca44c3861 Add database upgrade file 10.
NOTE: this is the first time we modify the actual data
in the database, as opposed to adding to the schema.
2022-02-07 17:05:19 +01:00
D. Berge
36e7b1fe21 Add database upgrade file 09 2022-02-06 23:26:57 +01:00
D. Berge
e7fa74326d Add README to database upgrades directory 2022-02-06 23:24:24 +01:00
D. Berge
b4569c14df Update database README.
Document how to create a Dougal database from scratch
and how to update PostgreSQL.
2022-02-06 22:28:21 +01:00
D. Berge
374fb7de67 Add database upgrade file 08 2021-10-04 02:21:00 +02:00
D. Berge
a280a910f5 Add database upgrade file 07 2021-09-11 12:19:06 +02:00
D. Berge
09f60d6c18 Add database upgrade file 06 2021-06-19 12:23:25 +02:00
D. Berge
81d9ea19cc Add adjust_planner() function to DB schema.
It updates the planned lines details according to production and current
time.
2021-06-19 12:18:28 +02:00
D. Berge
497d4d68f9 Call notify on changes to schema's info table 2021-06-19 12:17:26 +02:00
D. Berge
853deca3c3 Rename misnamed trigger 2021-06-19 12:16:37 +02:00
D. Berge
534a54ef75 Add database upgrade file 05 2021-05-28 20:30:59 +02:00
D. Berge
f314536daf Change planned_lines trigger from statement to row.
Because a) it tells us what has changed and b) doesn't fire if we
didn't actually change anything.
2021-05-28 20:30:59 +02:00
D. Berge
de4aa52417 Make planned_lines primary key deferrable.
Helps when we need to renumber sequences.
2021-05-28 20:30:59 +02:00
D. Berge
7d354ffdb6 Add database upgrade file 2021-05-25 02:21:11 +02:00
D. Berge
3d70a460ac Output raw and final lines metadata in summary views 2021-05-25 02:13:50 +02:00
D. Berge
5708ed1a11 Merge branch '57-make-event-log-entries-for-start-and-end-of-line-upon-import-of-final-sequence-if-the-entries-do' into 'devel'
Resolve "Make event log entries for start and end of line upon import of final sequence, if the entries do not already exist"

Closes #57

See merge request wgp/dougal/software!11
2021-05-24 15:44:58 +00:00
D. Berge
ad3998d4c6 Add database upgrade file 2021-05-24 17:41:11 +02:00
D. Berge
8638f42e6d Add database upgrade files.
These files contain the sequence of SQL commands needed to bring
a database or project schema up to date with the latest template
database or project schema.

These files must be applied manually. Check the comments at the top of
the file for instructions.
2021-05-24 17:39:01 +02:00
D. Berge
4d97784829 Upgrade database project schema template.
Adds:

* label_in_sequence (_sequence integer, _label text):
  Returns events containing the specified label.

* handle_final_line_events (_seq integer, _label text, _column text):
  - If _label does not exist in the events for sequence _seq:
    it adds a new _label label at the shotpoint obtained from
    final_lines_summary[_column].
  - If _label does exist (and hasn't been auto-added by this function
    in a previous run), it will add information about it to the final
    line's metadata.

* final_line_post_import (_seq integer):
  Calls handle_final_line_events() on the given sequence to check
  for FSP, FGSP, LGSP and LSP labels.

* events_seq_labels_single ():
  Trigger function to ensure that labels that have the attribute
  `model.multiple` set to `false` occur at most only once per
  sequence. If a new instance is added to a sequence, the previous
  instance is deleted.

* Trigger on events_seq_labels that calls events_seq_labels_single().

* Trigger on events_timed_labels that calls events_seq_labels_single().
2021-05-24 16:49:39 +02:00
D. Berge
53f71f7005 Set primary key on events_seq_labels in schema template 2021-05-23 22:27:00 +02:00
D. Berge
5de64e6b45 Add meta column to events view in schema template 2021-05-23 22:26:00 +02:00
D. Berge
7917eeeb0b Add table info to schema.
This one is independent of any projects so it goes
into `public`.
2021-05-20 18:07:05 +02:00
D. Berge
6e7ba82ed3 Add planner elements to DB schema 2020-10-09 13:54:45 +02:00
D. Berge
739cf4b9ec Add missing triggers in preplot, raw and final tables 2020-10-06 19:19:35 +02:00
D. Berge
afa34867f5 Modify functions accessing file_data to return jsonb.
Following schema change in 2d270cdef9.
2020-10-04 05:13:17 +02:00
D. Berge
3de7d5d334 Re-export schema template.
No changes, it merely shuffles the position of raw_lines
in the export.
2020-10-04 04:07:50 +02:00
D. Berge
3c215e9973 Fix error with definition of missing_final_points view 2020-10-04 04:06:15 +02:00
D. Berge
362d9dc1a5 Re-export schema template.
No changes, it merely shuffles the position of raw_lines
in the export.
2020-10-04 03:37:20 +02:00
D. Berge
1249c976ef Add views related to missing shots and outstanding production 2020-10-04 03:33:23 +02:00
D. Berge
2d270cdef9 Change file_data column type from JSON to JSONB 2020-10-04 01:22:42 +02:00
D. Berge
198d0072d4 Show sequence remarks + NTBP status on map.
Closes #50.
2020-10-02 17:58:44 +02:00
D. Berge
11a5020004 Remove old QCs when importing final shots.
When final shots are inserted, updated or
deleted, the corresponding QC info (which
is always held in raw_shots.meta->'qc')
is deleted.

If applicable, it will be recreated on the
next QC run.
2020-10-02 17:30:42 +02:00
D. Berge
c12c2a3861 Update events view.
Searches for timed events geometry within
the event's own metadata.
2020-09-30 22:49:01 +02:00
D. Berge
21439fdd3e Associate a position with timed events if possible.
When inserting or updating a timed event, a trigger
searches the real time events table for a position
close (within one minute) of the event time and
adds it to the event's metadata.
2020-09-30 22:45:50 +02:00
D. Berge
78adb2bef7 Make set_survey argument case insensitive 2020-09-26 22:53:48 +02:00
D. Berge
77aae68603 Include project ID in DB notifications 2020-09-25 18:27:59 +02:00
D. Berge
9470f41f4b Fix lookup of timed event labels.
Fixes #44.
2020-09-24 15:32:25 +02:00
D. Berge
4dc1c7df8e Re-export schema template.
No changes to the actual schema.
2020-09-24 15:31:53 +02:00
D. Berge
80324130f9 Return event geometries as GeoJSON 2020-09-24 15:24:47 +02:00
D. Berge
a4ed7f7b62 Return all QC events, not just those with labels 2020-09-23 20:19:13 +02:00
D. Berge
33c23c1239 Return event labels directly from events view.
This speeds up the query by orders of magnitude.
2020-09-23 16:31:55 +02:00
D. Berge
94c3ed1584 Update schema.
* Report also schema in projects_summary
* Add notify triggers to events_timed, events_seq
2020-09-14 23:54:48 +02:00
D. Berge
c9b9a009af Speed up the events view.
We do this with the help of some denormalisation
and a handy trigger.

Closes #35.
2020-09-14 03:01:55 +02:00
D. Berge
b5b91d41c9 Reset event serial ids after re-import.
When the database is recreated, the sequences
used in the events_timed and events_seq tables
will be at their initial values, which will
almost certainly conflict with existing data
when it is imported via COPY.

With this commit, we set the current value for
those sequences to something usable.

Fixes #33.
2020-09-14 01:36:40 +02:00
D. Berge
bda11cc22f Add raw_shots_preplots view.
Used by the QC routines.
2020-09-10 20:50:08 +02:00
D. Berge
48f2931a13 Change type of info table value to JSONB 2020-09-10 20:49:39 +02:00
D. Berge
906dcc6a7e Make event id serial rather than plain integer 2020-09-06 14:49:42 +02:00
D. Berge
4eb0a643c7 Merge branch '18-implement-server-push' into 'devel'
Resolve "Implement server push"

Closes #18

See merge request wgp/dougal/software!1
2020-09-06 12:30:33 +00:00
D. Berge
3e949f6185 Add meta fields to schema.
Many tables now have a JSON (jsonb) column to
hold unstructured data.
2020-09-06 13:37:11 +02:00