diff options
author | Aspen Smith <root@gws.fyi> | 2024-03-24T14·32-0400 |
---|---|---|
committer | aspen <root@gws.fyi> | 2024-03-31T19·22+0000 |
commit | a1a29f7c0b5746aa5676e546b8ebae7518d9070b (patch) | |
tree | f2343087d8d8b87f622c24115907a4bf7407c177 /web/panettone/default.nix | |
parent | d5f57ac6e68f3acd79f1abc91d8ee9afc435018f (diff) |
feat(web/panettone): Add a system for database migrations r/7826
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 <sternenseemann@systemli.org>
Diffstat (limited to 'web/panettone/default.nix')
-rw-r--r-- | web/panettone/default.nix | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/web/panettone/default.nix b/web/panettone/default.nix index 283f83499487..91ac34ea5482 100644 --- a/web/panettone/default.nix +++ b/web/panettone/default.nix @@ -1,4 +1,4 @@ -{ depot, ... }: +{ depot, pkgs, ... }: depot.nix.buildLisp.program { name = "panettone"; @@ -9,6 +9,7 @@ depot.nix.buildLisp.program { cl-ppcre cl-smtp cl-who + str defclass-std drakma easy-routes @@ -23,6 +24,14 @@ depot.nix.buildLisp.program { srcs = [ ./panettone.asd ./src/packages.lisp + (pkgs.writeText "build.lisp" '' + (defpackage build + (:use :cl :alexandria) + (:export :*migrations-dir*)) + (in-package :build) + (declaim (optimize (safety 3))) + (defvar *migrations-dir* "${./src/migrations}") + '') ./src/util.lisp ./src/css.lisp ./src/email.lisp |