File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,16 +28,16 @@ Or to your Leiningen project file:
2828Add the ` :duct.module/sql ` key to your Duct configuration:
2929
3030``` edn
31- {:duct.module/sql {}}
31+ {:duct.module/sql {:migrations #duct/include " migrations.edn " }}
3232```
3333This module uses the Integrant [ expand] [ ] function to add the
3434following keys to the configuration:
3535
3636* ` :duct.database.sql/hikaricp ` - a SQL datasource
3737* ` :duct.migrator/ragtime ` - applies database migrations
3838
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
39+ This will setup a pooled database connection and a migrator with
40+ migrations loaded from the ` migrations.edn ` include file . See the
4141documentation on [ Ragtime's SQL migrations] [ migrations ] for information
4242about the syntax.
4343
Original file line number Diff line number Diff line change 55 :url " http://www.eclipse.org/legal/epl-v10.html" }
66 :dependencies [[org.clojure/clojure " 1.12.2" ]
77 [org.duct-framework/database.sql.hikaricp " 0.7.1" ]
8- [org.duct-framework/migrator.ragtime " 0.5.3 " ]
8+ [org.duct-framework/migrator.ragtime " 0.6.0 " ]
99 [org.duct-framework/repl.refers " 0.1.0" ]
1010 [integrant " 1.0.0" ]
1111 [com.github.seancorfield/next.jdbc " 1.3.1070" ]]
Original file line number Diff line number Diff line change 11(ns duct.module.sql
22 (:require [integrant.core :as ig]))
33
4- (defmethod ig /expand-key :duct.module/sql [_ _ ]
4+ (defmethod ig /expand-key :duct.module/sql [_ { :keys [migrations]} ]
55 (let [components {:duct.database.sql/hikaricp
66 {:logger (ig/refset :duct/logger )
77 :jdbcUrl (ig/var 'jdbc-url)}
88 :duct.migrator/ragtime
9- {:logger (ig/refset :duct/logger )
10- :database (ig/ref :duct.database/sql )
11- :strategy :rebase
12- :migrations-file " migrations.edn " }}]
9+ {:logger (ig/refset :duct/logger )
10+ :database (ig/ref :duct.database/sql )
11+ :strategy :rebase
12+ :migrations migrations}}]
1313 (ig/profile
1414 :main (assoc-in components [:duct.migrator/ragtime :strategy ]
1515 :raise-error )
Original file line number Diff line number Diff line change 66 :doc " The JDBC database URL" }}
77 :doc
88 " A module that adds components for accessing SQL databases to the
9- configuration. Takes no options.
9+ configuration.
10+
11+ Takes the following option:
12+ - `:migrations` - a data structure of [Ragtime SQL Migrations][1]
1013
1114 In the `:repl` profile, migrations are run using the `:rebase` strategy
1215 (conflicts replace existing migrations), while in the `:main` profile the
1619 - `db` - get a `DataSource` of the running system's database
1720 - `sql` - run a SQL statement on the system's database
1821
19- A Duct `jdbc-url` variable is added to configure the JDBC database URL." }}
22+ A Duct `jdbc-url` variable is added to configure the JDBC database URL.
23+
24+ [1]: https://github.com/weavejester/ragtime/wiki/SQL-Migrations#edn" }}
Original file line number Diff line number Diff line change 1414 {:database (ig/ref :duct.database/sql )
1515 :logger (ig/refset :duct/logger )
1616 :strategy :raise-error
17- :migrations-file " migrations.edn" }}
18- (-> {:duct.module/sql {}}
17+ :migrations '[[:create-table foo (id " INTEGER" )]]}}
18+ (-> {:duct.module/sql
19+ {:migrations '[[:create-table foo (id " INTEGER" )]]}}
1920 (ig/expand (ig/deprofile [:main ]))
2021 (ig/bind {'jdbc-url " jdbc:sqlite:" })))))
2122
2728 {:database (ig/ref :duct.database/sql )
2829 :logger (ig/refset :duct/logger )
2930 :strategy :rebase
30- :migrations-file " migrations.edn " }
31+ :migrations '[[ :create-table foo ( id " INTEGER " )]] }
3132 :duct.repl/refers
3233 '{db duct.repl.sql/db
3334 sql duct.repl.sql/sql}}
34- (-> {:duct.module/sql {}}
35+ (-> {:duct.module/sql
36+ {:migrations '[[:create-table foo (id " INTEGER" )]]}}
3537 (ig/expand (ig/deprofile [:repl ]))
3638 (ig/bind {'jdbc-url " jdbc:sqlite:" })))))
3739
4345 {:database (ig/ref :duct.database/sql )
4446 :logger (ig/refset :duct/logger )
4547 :strategy :rebase
46- :migrations-file " migrations.edn" }}
47- (-> {:duct.module/sql {}}
48+ :migrations '[[:create-table foo (id " INTEGER" )]]}}
49+ (-> {:duct.module/sql
50+ {:migrations '[[:create-table foo (id " INTEGER" )]]}}
4851 (ig/expand (ig/deprofile [:test ]))
4952 (ig/bind {'jdbc-url " jdbc:sqlite:" }))))))
You can’t perform that action at this time.
0 commit comments