Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support sqlite #34

Open
chamanbravo opened this issue Mar 6, 2024 · 11 comments · May be fixed by #43
Open

feat: support sqlite #34

chamanbravo opened this issue Mar 6, 2024 · 11 comments · May be fixed by #43
Assignees
Labels
backend Backend enhancement New feature or request

Comments

@chamanbravo
Copy link
Owner

chamanbravo commented Mar 6, 2024

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

@chamanbravo chamanbravo added enhancement New feature or request backend Backend labels Mar 6, 2024
@jeyren95
Copy link
Contributor

hi can i take this?

@chamanbravo
Copy link
Owner Author

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.

@jeyren95
Copy link
Contributor

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?

@chamanbravo
Copy link
Owner Author

yeah, I think having only one migration script would be great.

@jeyren95
Copy link
Contributor

hmmm ok i need to dig deeper to see if this is possible

@chamanbravo
Copy link
Owner Author

we can remove pgcrypto and use crypto library. So the script can work for both.

@jeyren95
Copy link
Contributor

jeyren95 commented Mar 17, 2024

ok yeah that works, i'll implement the crypto library in this PR too

@jeyren95
Copy link
Contributor

jeyren95 commented Mar 24, 2024

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:

  1. Using integer primary key autoincrement - does not work because postgres does not support autoincrement
  2. Using integer primary key generated always as identity - does not work because not supported by sqlite
  3. UUID extension - does not work because the not supported by sqlite

@jeyren95
Copy link
Contributor

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

@chamanbravo
Copy link
Owner Author

Hey thank you for trying, if having a single script for migration doesn't seem possible, we can create different scripts then...

@jeyren95 jeyren95 linked a pull request Mar 24, 2024 that will close this issue
10 tasks
@jeyren95
Copy link
Contributor

opened a PR to resolve this issue #43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Backend enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants