Skip to content

Instantly share code, notes, and snippets.



Created Jul 7, 2020
What would you like to do?
cl-migratum example
(defvar *connection-pool*
(anypool:make-pool :name "dbi-connections"
:connector (lambda ()
(dbi:connect :postgres
:database-name (uiop:getenv "POSTGRES_DATABASE_NAME")
:host (uiop:getenv "POSTGRES_HOST")
:port (parse-integer (uiop:getenv "POSTGRES_PORT"))
:username (uiop:getenv "POSTGRES_USERNAME")
:password (uiop:getenv "POSTGRES_PASSWORD")))
:disconnector #'dbi:disconnect
:max-open-count (parse-integer (uiop:getenv "CONNECTION_POOL_OPEN_COUNT"))
:max-idle-count (parse-integer (uiop:getenv "CONNECTION_POOL_IDLE_COUNT"))))
(defun start-migrations ()
(anypool:with-connection (connection *connection-pool*)
(let* ((provider (migratum.provider.local-path:make-local-path-provider
(asdf:system-relative-pathname "todo" #p"migrations/")))
(driver (migratum.driver.sql:make-sql-driver provider connection)))
(migratum:provider-init provider)
(migratum:driver-init driver)
(migratum:apply-pending driver))))
(defun start ()
:interface (uiop:getenv "WEB_INTERFACE")
:port (parse-integer (uiop:getenv "WEB_PORT")))
(when (uiop:getenvp "DEBUG")
(log4cl:log-config :debug)))
create extension "uuid-ossp";
create table todo (
id uuid primary key default uuid_generate_v1mc(),
title text not null,
done boolean not null default false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment