pgstac
pgstac copied to clipboard
Multiple pgstac.migrations records can have same timestamp
I was testing out pgstac migrations (with pypgstac migrate
) and it looks like multiple version numbers can be inserted at the same time.
db=> SELECT * FROM pgstac.migrations;
version | datetime
---------+-------------------------------
0.2.4 | 2021-08-24 18:34:59.364497+00
0.2.7 | 2021-08-24 18:39:26.047286+00
0.3.4 | 2021-08-24 18:39:26.124702+00
0.2.8 | 2021-08-24 18:39:26.129415+00
0.3.4 | 2021-08-24 18:39:26.133057+00
0.2.9 | 2021-08-24 18:39:26.136371+00
0.3.4 | 2021-08-24 18:39:26.136371+00
(7 rows)
0.2.4
was added to the table manually, but all other rows were added as part of pypgstac migrate
. This is an issue because pypgstac migrate
picks up the most-recently-added row
https://github.com/stac-utils/pgstac/blob/6e43fb3e691fb04376474ed122b5de15c55375d5/pypgstac/pypgstac/migrate.py#L113-L118
db=> SELECT version FROM pgstac.migrations
db-> ORDER BY datetime DESC LIMIT 1;
version
---------
0.2.9
(1 row)
If pgstac is dedicated to Semver, you could just take Max(version)
and use lexicographic sort on the string?
db=> SELECT MAX(version) FROM pgstac.migrations;
max
-------
0.3.4
(1 row)
@bitner was this fixed in #57 ?
I haven't tested this since #57 was merged and released but I suspect it might be fixed.