1
1
# Duct module.sql [ ![ Build Status] ( https://github.com/duct-framework/module.sql/actions/workflows/test.yml/badge.svg )] ( https://github.com/duct-framework/module.sql/actions/workflows/test.yml )
2
2
3
- A [ Duct] [ ] module that adds [ Integrant] [ ] keys for a [ hikari-cp ] [ ] SQL
3
+ A [ Duct] [ ] module that adds [ Integrant] [ ] keys for a [ HikariCP ] [ ] SQL
4
4
database connection pool and [ Ragtime] [ ] migrations to a configuration.
5
5
6
+ This current version is experimental and will only work with the new
7
+ [ duct.main] [ ] tool. The artifact group name has been changed to prevent
8
+ accidental upgrades. The version prior to this change was: ` 0.6.1 ` .
9
+
6
10
[ duct ] : https://github.com/duct-framework/duct
7
11
[ Integrant ] : https://github.com/weavejester/integrant
8
- [ hikari-cp ] : https://github.com/tomekw/hikari-cp
12
+ [ hikaricp ] : https://github.com/brettwooldridge/HikariCP
9
13
[ ragtime ] : https://github.com/weavejester/ragtime
14
+ [ duct.main ] : https://github.com/duct-framework/duct.main
10
15
11
16
## Installation
12
17
@@ -20,57 +25,33 @@ Or to your Leiningen project file:
20
25
21
26
## Usage
22
27
23
- To add this module to your configuration, add the ` :duct.module/sql `
24
- key to your ` config.edn ` file:
25
-
26
- ``` edn
27
- :duct.module/sql {}
28
- ```
29
-
30
- #### Optional Module Parameters
31
-
32
- ``` edn
33
- :database-url STRING
34
- ```
35
- JDBC URL for the connection pool. Overridden by ` JDBC_DATABASE_URL ` ,
36
- ` DATABASE_URL ` environment variables or custom ` :duct.database/sql `
37
- integrant key.
38
-
39
- #### Integrant Keys
40
-
41
- When prepped, the module will compile the following Integrant keys into
42
- your config:
43
-
28
+ Add the ` :duct.module/sql ` key to your Duct configuration:
44
29
45
30
``` edn
46
- :duct.database.sql/hikaricp {
47
- :jdbc-url URL
48
- :logger #ig/ref :duct/logger
49
- }
50
-
51
- :duct.migrator/ragtime {
52
- :database #ig/ref :duct.database/sql
53
- :strategy STRATEGY
54
- :logger #ig/ref :duct/logger
55
- :migrations []
56
- }
31
+ {:duct.module/sql {}}
57
32
```
33
+ This module uses the Integrant [ expand] [ ] function to add the
34
+ following keys to the configuration:
58
35
59
- These defaults can be (selectively) overridden through custom
60
- ` :duct.database/sql ` (or ` :duct.database.sql/hikaricp ` ) and
61
- ` :duct.migrator/ragtime ` keys in your duct profiles.
36
+ * ` :duct.database.sql/hikaricp ` - a SQL datasource
37
+ * ` :duct.migrator/ragtime ` - applies database migrations
62
38
63
- ` URL ` is either overridden, set by the ` :database-url ` module parameter
64
- or provided by the ` JDBC_DATABASE_URL ` and ` DATABASE_URL ` environment
65
- variables, in this order.
39
+ This will setup a pooled database connection and a migrator that looks
40
+ for a file ` migrations.edn ` in the current directory. See the
41
+ documentation on [ Ragtime's SQL migrations] [ migrations ] for information
42
+ about the syntax.
66
43
67
- ` STRATEGY ` is ` :raise-error ` for ` :production ` environment,
68
- ` :rebase ` for ` :development ` .
44
+ The JDBC URL is supplied via the ` jdbc-url ` var. This can be set via the
45
+ ` --jdbc-url ` command line argument of duct.main, or using the
46
+ ` JDBC_DATABASE_URL ` environment variable.
69
47
70
- ##### Key Documentation:
48
+ In the ` :main ` profile, the Ragtime migration strategy is set to
49
+ ` :raise-error ` , which will raise an error if there's a conflict. In the
50
+ ` :repl ` profile, the migration strategy is set to ` :rebase ` , which will
51
+ attempt to roll back migrations to the conflict, then reapply them all.
71
52
72
- * [ database.sql.hikaricp ] ( https://github.com/duct-framework/database.sql.hikaricp )
73
- * [ migrator.ragtime ] ( https://github.com/duct-framework/migrator. ragtime )
53
+ [ expand ] : https://github.com/weavejester/integrant#expanding
54
+ [ migrations ] : https://github.com/weavejester/ ragtime/wiki/SQL-Migrations#edn
74
55
75
56
## License
76
57
0 commit comments