Switching from sqlite to postgres #53
-
What would be the correct approach to switch the storage from sqlite to postgres? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @Jimmy99. Good question. It depends if you need to support both SQLite & Postgres or if you're just moving to Postgres. If you're moving to Postgres (and removing SQLite support) then I would create a If you're supporting both Postgres & SQLite, you could either add a |
Beta Was this translation helpful? Give feedback.
Hi @Jimmy99. Good question. It depends if you need to support both SQLite & Postgres or if you're just moving to Postgres.
If you're moving to Postgres (and removing SQLite support) then I would create a
postgres
package for the code and update thesqlite
references incmd/wtfd/main.go
. The other packages shouldn't have knowledge of the underlying implementation—only themain
package that wires it all together.If you're supporting both Postgres & SQLite, you could either add a
postgres
package and keep thesqlite
package or you could look at implementing SQL support using some kind of generic ORM tool. In that case, I would move the code into asql
package that would support both.