V215: where a photo was taken, in two columns a map can ask about.
phoenix_kit_files.latitude and longitude are the GPS position the photo's
EXIF records, in decimal degrees (WGS 84: latitude -90..90, longitude
-180..180), NULL for a file with none. They are columns, not part of the
file's metadata, because a map asks "what is in this area?" and answers
with an index.
The index is a GiST index on point(longitude, latitude), built into
Postgres (no PostGIS, no extension to install, nothing to do with a named
schema): a box on the map is one indexed lookup,
WHERE point(longitude, latitude) <@ box(point(west, south), point(east, north))(PhoenixKit.Modules.Storage.Geo builds it, and splits a box that crosses the
antimeridian in two). It is partial, over files that have a position, so a
library of photos without GPS pays nothing for it.
The rest of the EXIF a photo carries (camera, lens, exposure, dates, altitude,
speed, direction) is kept in metadata["exif"]; the position is both there
and here, this being the copy that is indexed. No existing file is changed by
this migration: the position of a photo already uploaded is read by
Storage.read_exif/1.
Locks
ADD COLUMN of two nullable columns (no default, no rewrite) and a plain
index build (the chain's convention, see V193), so writes to
phoenix_kit_files wait while it builds; the index is partial, so it holds
only the files with a position, and none yet. Re-runnable.
Summary
Functions
Rolls V215 back: the index and the two columns go.