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 505a26e..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" @@ -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..2b6e9c7 --- /dev/null +++ b/src/postgresql_component/migrations.clj @@ -0,0 +1,16 @@ +(ns postgresql-component.migrations + (:require [clojure.tools.logging :as log] + [integrant.core :as ig] + [pg.migration.core :as migrations])) + +(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 + [_ _] + (log/info :stopping ::postgresql-migrations))