From 1831e89dbb561ac5df30e48b2b4e6ebee08c5d4d Mon Sep 17 00:00:00 2001 From: Bruno do Nascimento Maciel Date: Fri, 2 Jan 2026 22:04:26 -0300 Subject: [PATCH 1/3] implement migrations component --- project.clj | 20 ++++++++++---------- src/postgresql_component/migrations.clj | 17 +++++++++++++++++ 2 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 src/postgresql_component/migrations.clj diff --git a/project.clj b/project.clj index 505a26e..7aadef4 100644 --- a/project.clj +++ b/project.clj @@ -7,24 +7,24 @@ :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0" :url "https://www.eclipse.org/legal/epl-2.0/"} - :plugins [[com.github.clojure-lsp/lein-clojure-lsp "1.4.16"] + :plugins [[com.github.clojure-lsp/lein-clojure-lsp "2.0.13"] [com.github.liquidz/antq "RELEASE"] [lein-shell "0.5.0"]] - :dependencies [[org.clojure/clojure "1.12.0"] - [io.pedestal/pedestal.interceptor "0.7.2"] - [com.github.igrishaev/pg2-core "0.1.33"] - [org.clojure/tools.logging "1.3.0"] - [integrant "0.13.1"]] + :dependencies [[org.clojure/clojure "1.12.4"] + [io.pedestal/pedestal.interceptor "0.8.1"] + [com.github.igrishaev/pg2-core "0.1.41"] + [org.clojure/tools.logging "1.3.1"] + [integrant "1.0.1"]] :profiles {:dev {:resource-paths ^:replace ["test/resources"] :test-paths ^:replace ["test/unit" "test/integration" "test/helpers"] - :dependencies [[com.github.igrishaev/pg2-migration "0.1.33"] - [nubank/matcher-combinators "3.9.1"] - [org.slf4j/slf4j-api "2.0.16"] - [ch.qos.logback/logback-classic "1.5.16"] + :dependencies [[com.github.igrishaev/pg2-migration "0.1.41"] + [nubank/matcher-combinators "3.9.2"] + [org.slf4j/slf4j-api "2.0.17"] + [ch.qos.logback/logback-classic "1.5.23"] [prismatic/schema "1.4.1"] [clojure.java-time "1.4.3"] [hashp "0.2.2"]] diff --git a/src/postgresql_component/migrations.clj b/src/postgresql_component/migrations.clj new file mode 100644 index 0000000..451f8f9 --- /dev/null +++ b/src/postgresql_component/migrations.clj @@ -0,0 +1,17 @@ +(ns postgresql-component.migrations + (:require [pg.migration.core :as migrations] + [clojure.tools.logging :as log] + [integrant.core :as ig])) + +(defmethod ig/init-key ::postgresql-migrations + [_ {:keys [components]}] + (log/info :starting ::postgresql-migrations) + (let [postgresql-config (-> components :config :postgresql) + migrations-config (-> components :config :postgresql-migrations) + configuration (merge postgresql-config migrations-config)] + (migrations/migrate-all configuration))) + +(defmethod ig/halt-key! ::postgresql-migrations + [_ pool] + (log/info :stopping ::postgresql-migrations) + (pg.core/close pool)) From fe6224531fcd291cce31a51fdccb9cf41096f038 Mon Sep 17 00:00:00 2001 From: Bruno do Nascimento Maciel Date: Fri, 2 Jan 2026 22:26:57 -0300 Subject: [PATCH 2/3] initial implementation --- CHANGELOG.md | 8 ++++++-- project.clj | 2 +- src/postgresql_component/migrations.clj | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86da157..3aa76c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,13 @@ All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). -## Unreleased +## 2.3.5 - 2026-01-02 -## 2.2.4 - 2025-02-01 +### Added + +- Implement migrations component. + +## 2.2.5 - 2025-02-01 ### Changed diff --git a/project.clj b/project.clj index 7aadef4..e0a193d 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject net.clojars.macielti/postgresql-component "2.2.5" +(defproject net.clojars.macielti/postgresql-component "2.3.5" :description "PostgreSQL Component" diff --git a/src/postgresql_component/migrations.clj b/src/postgresql_component/migrations.clj index 451f8f9..307379f 100644 --- a/src/postgresql_component/migrations.clj +++ b/src/postgresql_component/migrations.clj @@ -1,7 +1,7 @@ (ns postgresql-component.migrations - (:require [pg.migration.core :as migrations] - [clojure.tools.logging :as log] - [integrant.core :as ig])) + (:require [clojure.tools.logging :as log] + [integrant.core :as ig] + [pg.migration.core :as migrations])) (defmethod ig/init-key ::postgresql-migrations [_ {:keys [components]}] From d6e0b908dd35bbb9672180371b206958c63d2253 Mon Sep 17 00:00:00 2001 From: Bruno do Nascimento Maciel Date: Fri, 2 Jan 2026 22:29:04 -0300 Subject: [PATCH 3/3] fix stop function --- src/postgresql_component/migrations.clj | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/postgresql_component/migrations.clj b/src/postgresql_component/migrations.clj index 307379f..2b6e9c7 100644 --- a/src/postgresql_component/migrations.clj +++ b/src/postgresql_component/migrations.clj @@ -12,6 +12,5 @@ (migrations/migrate-all configuration))) (defmethod ig/halt-key! ::postgresql-migrations - [_ pool] - (log/info :stopping ::postgresql-migrations) - (pg.core/close pool)) + [_ _] + (log/info :stopping ::postgresql-migrations))