Clivern / Lynx

🐺 A Fast, Secure and Reliable Terraform Backend, Set up in Minutes.
https://lynx.clivern.com/
MIT License
273 stars 7 forks source link

Support SQLite as a database #80

Open taraio opened 5 months ago

taraio commented 5 months ago

Is your feature request related to a problem? Please describe. Add support for sqlite using ecto_sqlite3 https://github.com/elixir-sqlite/ecto_sqlite3

Clivern commented 5 months ago

Actually i wanted to support SQLite for small setups and testings but sadly it doesn't support SELECT ... FOR UPDATE OF. Currently i use that for locking support, to lock an environment from a concurrent updates.

Reference https://www2.sqlite.org/cvstrac/wiki?p=UnsupportedSql

SELECT ... FOR UPDATE OF ... is not supported. This is understandable considering the mechanics of SQLite
 in that row locking is redundant as the entire database is locked when updating any bit of it. 
However, it would be good if a future version of SQLite supports it for SQL interchageability reasons if nothing else. 
The only functionality required is to ensure a "RESERVED" lock is placed on the database if not already there.
taraio commented 5 months ago

Maybe we can switch to ecto locks https://hexdocs.pm/ecto/Ecto.Changeset.html#optimistic_lock/3. Not sure if it fits as replacement or not. it does fetch a version and update with that version so other update requests will fail if they try to update since they use stale version.