feat: support sqlite
Sqlite support will make it faster and easier to setup. But don't replace postgres with sqlite. Some might want to add a external database. You can keep both like this.
https://github.com/create-go-app/fiber-go-template/blob/master/platform/database/open_db_connection.go
hi can i take this?
hi can i take this?
Yeah sure. Please check out the link before adding. Try to keep both sqlite and postgres. Add a new env var db_type, keep sqlite default... And make sure migrations work properly for both. Thank you.
the current migration script requires creating the pgcrypto extension, but i dont think sqlite has that
are you looking to maintain only 1 migration script for both DB types?
yeah, I think having only one migration script would be great.
hmmm ok i need to dig deeper to see if this is possible
we can remove pgcrypto and use crypto library. So the script can work for both.
ok yeah that works, i'll implement the crypto library in this PR too
There is another issue with trying to support both postgres and sqlite with the same script:
- Postgres supports the "SERIAL" data type, but sqlite does not, making the id column difficult to synchronize between postgres and sqlite
Ways that i tried to resolve this but does not work:
- Using integer primary key autoincrement - does not work because postgres does not support autoincrement
- Using integer primary key generated always as identity - does not work because not supported by sqlite
- UUID extension - does not work because the not supported by sqlite
not sure if you might have seen a solution for this somewhere, but we might have to end up having separate scripts if you do want to support both database types
Hey thank you for trying, if having a single script for migration doesn't seem possible, we can create different scripts then...
opened a PR to resolve this issue https://github.com/chamanbravo/upstat/pull/43