@@ -1103,7 +1103,7 @@ Our project dependencies should now look like this:
1103
1103
org.duct-framework/main {:mvn/version "0.3.0"}
1104
1104
org.duct-framework/module.logging {:mvn/version "0.6.6"}
1105
1105
org.duct-framework/module.web {:mvn/version "0.13.2"}
1106
- org.duct-framework/module.sql {:mvn/version "0.8.1 "}
1106
+ org.duct-framework/module.sql {:mvn/version "0.9.0 "}
1107
1107
org.xerial/sqlite-jdbc {:mvn/version "3.50.3.0"}
1108
1108
com.github.seancorfield/next.jdbc {:mvn/version "1.3.1070"}}
1109
1109
:aliases {:duct {:main-opts ["-m" "duct.main"]}}}
@@ -1233,12 +1233,32 @@ a migration.
1233
1233
1234
1234
=== SQL Migrations
1235
1235
1236
- Part of the SQL module is to add a **migrator**, a component that will
1237
- manage database migrations. By default the
1238
- https://github.com/weavejester/ragtime[Ragtime] library is used, and
1239
- looks for a `migrations.edn` file in your project directory .
1236
+ One of the things the SQL module adds is a **migrator**, a component
1237
+ that will manage database migrations. By default the
1238
+ https://github.com/weavejester/ragtime[Ragtime] migration library is
1239
+ used .
1240
1240
1241
- Let's create a migration for a table to store the todo list items.
1241
+ The migrations are supplied via the `:migrations` key on the module. As
1242
+ there may be many migrations, it's worth separating these out into their
1243
+ own file via the `#duct/include` tag.
1244
+
1245
+ .duct.edn
1246
+ [,clojure]
1247
+ ----
1248
+ {:vars {jdbc-url {:default "jdbc:sqlite:todo.db"}}
1249
+ :system
1250
+ {:duct.module/logging {}
1251
+ :duct.module/sql
1252
+ {:migrations #duct/include "migrations.edn"}
1253
+ :duct.module/web
1254
+ {:features #{:site :hiccup}
1255
+ :handler-opts {:db #ig/ref :duct.database/sql}
1256
+ :routes [["/" {:get :todo.routes/index}]]}}}
1257
+ ----
1258
+
1259
+ In the above case, we've separated out the migrations into the
1260
+ `migrations.edn` file. Let's add a migration to this file that will
1261
+ create a table to store the todo list items.
1242
1262
1243
1263
.migrations.edn
1244
1264
[,clojure]
@@ -1348,7 +1368,8 @@ the POST.
1348
1368
{:vars {jdbc-url {:default "jdbc:sqlite:todo.db"}}
1349
1369
:system
1350
1370
{:duct.module/logging {}
1351
- :duct.module/sql {}
1371
+ :duct.module/sql
1372
+ {:migrations #duct/include "migrations.edn"}
1352
1373
:duct.module/web
1353
1374
{:features #{:site :hiccup}
1354
1375
:handler-opts {:db #ig/ref :duct.database/sql}
@@ -1427,7 +1448,7 @@ ClojureScript. As always we begin with our dependencies, and add the
1427
1448
org.duct-framework/module.cljs {:mvn/version "0.5.2"}
1428
1449
org.duct-framework/module.logging {:mvn/version "0.6.6"}
1429
1450
org.duct-framework/module.web {:mvn/version "0.13.2"}
1430
- org.duct-framework/module.sql {:mvn/version "0.8.1 "}
1451
+ org.duct-framework/module.sql {:mvn/version "0.9.0 "}
1431
1452
org.xerial/sqlite-jdbc {:mvn/version "3.50.3.0"}
1432
1453
com.github.seancorfield/next.jdbc {:mvn/version "1.3.1070"}}
1433
1454
:aliases {:duct {:main-opts ["-m" "duct.main"]}}}
@@ -1445,7 +1466,8 @@ configuration file.
1445
1466
{:vars {jdbc-url {:default "jdbc:sqlite:todo.db"}}
1446
1467
:system
1447
1468
{:duct.module/logging {}
1448
- :duct.module/sql {}
1469
+ :duct.module/sql
1470
+ {:migrations #duct/include "migrations.edn"}
1449
1471
:duct.module/cljs
1450
1472
{:builds {:client todo.client}}
1451
1473
:duct.module/web
@@ -1535,7 +1557,8 @@ to communicate with the server.
1535
1557
{:vars {jdbc-url {:default "jdbc:sqlite:todo.db"}}
1536
1558
:system
1537
1559
{:duct.module/logging {}
1538
- :duct.module/sql {}
1560
+ :duct.module/sql
1561
+ {:migrations #duct/include "migrations.edn"}
1539
1562
:duct.module/cljs {:builds {:client todo.client}}
1540
1563
:duct.module/web
1541
1564
{:features #{:site :api}
@@ -1633,7 +1656,7 @@ This requires us to once again update the project dependencies:
1633
1656
org.duct-framework/module.cljs {:mvn/version "0.5.2"}
1634
1657
org.duct-framework/module.logging {:mvn/version "0.6.6"}
1635
1658
org.duct-framework/module.web {:mvn/version "0.13.2"}
1636
- org.duct-framework/module.sql {:mvn/version "0.8.1 "}
1659
+ org.duct-framework/module.sql {:mvn/version "0.9.0 "}
1637
1660
org.xerial/sqlite-jdbc {:mvn/version "3.50.3.0"}
1638
1661
com.github.seancorfield/next.jdbc {:mvn/version "1.3.1070"}
1639
1662
no.cjohansen/replicant {:mvn/version "2025.06.21"}}
0 commit comments