From a1a29f7c0b5746aa5676e546b8ebae7518d9070b Mon Sep 17 00:00:00 2001 From: Aspen Smith Date: Sun, 24 Mar 2024 10:32:15 -0400 Subject: feat(web/panettone): Add a system for database migrations Add a system for writing, running, and tracking database migrations (changes to the database schema) over time, inspired by but significantly simpler than postmodern-passenger-pigeon. Migrations can be generated by running (PANETTONE.MODEL:GENERATE-MIGRATION "name"), and are numerically ordered lisp files that define (at least) a function called UP, which runs the migration. The migrations that have been run against the database are tracked in the `migrations` table, and when the `(PANETTONE.MODEL:MIGRATE)` function is called (as it is on startup), all migrations that have not yet been run are run within a transaction. This includes one migration `1-init-schema.lisp`, which migrates the database (idempotently) to the current state of the schema. Change-Id: Id243a47763abea649784b12f25a6d05c2267381c Reviewed-on: https://cl.tvl.fyi/c/depot/+/11253 Tested-by: BuildkiteCI Reviewed-by: sterni --- web/panettone/src/panettone.lisp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web/panettone/src/panettone.lisp') diff --git a/web/panettone/src/panettone.lisp b/web/panettone/src/panettone.lisp index d87ac5ed4653..bdcf0d05b39b 100644 --- a/web/panettone/src/panettone.lisp +++ b/web/panettone/src/panettone.lisp @@ -606,7 +606,7 @@ given subject an body (in a thread, to avoid blocking)" (defun migrate-db () "Migrate the database to the latest version of the schema" (pomo:with-connection *pg-spec* - (model:ddl/init))) + (model:migrate))) (defun start-panettone (&key port session-secret) (authn:initialise-oauth2) -- cgit 1.4.1