Skip to content

Commit 2ccfd9a

Browse files
committed
refactor out sql module. add postgres module. make sqlite module depends on sql module
1 parent 0d16e13 commit 2ccfd9a

File tree

8 files changed

+60
-38
lines changed

8 files changed

+60
-38
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

metrics/config.edn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
:path "deps.edn"
77
:target [:deps]
88
:action :merge
9-
:value {io.github.kit-clj/kit-metrics {:mvn/version "1.0.1"}}}
9+
:value {io.github.kit-clj/kit-metrics {:mvn/version "1.0.2"}}}
1010
{:type :edn
1111
:path "resources/system.edn"
1212
:target []

modules.edn

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@
66
:kit/metrics
77
{:path "metrics"
88
:doc "adds support for metrics using prometheus through iapetos"}
9+
:kit/sql
10+
{:path "sql"
11+
:doc "adds generic SQL support. Requires manual database driver setup"}
912
:kit/sqlite
1013
{:path "sqlite"
1114
:doc "adds support for SQLite embedded database"}
15+
:kit/postgres
16+
{:path "postgres"
17+
:doc "adds support for PostgreSQL database"}
1218
:kit/cljs
1319
{:path "cljs"
1420
:doc "adds support for cljs using shadow-cljs"}

postgres/config.edn

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{:default
2+
{:require-restart? true
3+
:requires [:kit/sql]
4+
:actions
5+
{:injections [{:type :edn
6+
:path "resources/system.edn"
7+
:target []
8+
:action :merge
9+
:value {:db.sql/connection #profile
10+
{:dev {:jdbc-url "jdbc:postgresql://localhost:5432/<<name>>_dev?user=<<name>>&password=<<name>>"}
11+
:test {:jdbc-url "jdbc:postgresql://localhost:5432/<<name>>_test?user=<<name>>&password=<<name>>"}
12+
:prod {:jdbc-url #env JDBC_URL}}}}
13+
{:type :edn
14+
:path "deps.edn"
15+
:target [:deps]
16+
:action :merge
17+
:value {org.postgresql/postgresql {:mvn/version "42.3.4"}}}]}}}

sql/assets/queries.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-- Place your queries here. Docs available https://www.hugsql.org/

sql/config.edn

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{:default
2+
{:require-restart? true
3+
:actions
4+
{:assets [["assets/queries.sql" "resources/sql/queries.sql"]
5+
"resources/migrations"]
6+
:injections [{:type :edn
7+
:path "resources/system.edn"
8+
:target []
9+
:action :merge
10+
:value {:db.sql/connection #profile
11+
{:dev {:jdbc-url "jdbc:TODO"}
12+
:test {:jdbc-url "jdbc:TODO"}
13+
:prod {:jdbc-url #env JDBC_URL}}
14+
:db.sql/query-fn {:conn #ig/ref :db.sql/connection
15+
:options {}
16+
:filename "sql/queries.sql"}
17+
:db.sql/migrations {:store :database
18+
:db {:datasource #ig/ref :db.sql/connection}
19+
:migrate-on-init? true}}}
20+
{:type :edn
21+
:path "deps.edn"
22+
:target [:deps]
23+
:action :merge
24+
:value {io.github.kit-clj/kit-sql-conman {:mvn/version "1.0.1"}
25+
io.github.kit-clj/kit-sql-migratus {:mvn/version "1.0.0"}}}
26+
{:type :clj
27+
:path "src/clj/<<sanitized>>/core.clj"
28+
:action :append-requires
29+
:value ["[kit.edge.db.sql.conman]
30+
[kit.edge.db.sql.migratus]"]}]}}}

sqlite/assets/queries.sql

Lines changed: 0 additions & 21 deletions
This file was deleted.

sqlite/config.edn

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,17 @@
11
{:default
22
{:require-restart? true
3+
:requires [:kit/sql]
34
:actions
4-
{:assets [["assets/queries.sql" "resources/sql/queries.sql"]
5-
"resources/migrations"]
6-
:injections [{:type :edn
5+
{:injections [{:type :edn
76
:path "resources/system.edn"
87
:target []
98
:action :merge
109
:value {:db.sql/connection #profile
1110
{:dev {:jdbc-url "jdbc:sqlite:<<name>>_dev.db"}
1211
:test {:jdbc-url "jdbc:sqlite:<<name>>_test.db"}
13-
:prod {:jdbc-url #env JDBC_URL}}
14-
:db.sql/query-fn {:conn #ig/ref :db.sql/connection
15-
:options {}
16-
:filename "sql/queries.sql"}
17-
:db.sql/migrations {:store :database
18-
:db {:datasource #ig/ref :db.sql/connection}
19-
:migrate-on-init? true}}}
12+
:prod {:jdbc-url #env JDBC_URL}}}}
2013
{:type :edn
2114
:path "deps.edn"
2215
:target [:deps]
2316
:action :merge
24-
:value {io.github.kit-clj/kit-sql {:mvn/version "1.0.0"}
25-
org.xerial/sqlite-jdbc {:mvn/version "3.36.0.3"}}}
26-
{:type :clj
27-
:path "src/clj/<<sanitized>>/core.clj"
28-
:action :append-requires
29-
:value ["[kit.edge.db.sql]"]}]}}}
17+
:value {org.xerial/sqlite-jdbc {:mvn/version "3.36.0.3"}}}]}}}

0 commit comments

Comments
 (0)