From 2c52f0861e11951631ac059f90c638caec815e69 Mon Sep 17 00:00:00 2001 From: "@tanya_r" Date: Thu, 18 Jun 2026 21:28:19 -0300 Subject: [PATCH] feat(sandbox): add demo seed accounts via a context-gated liquibase changeset A fresh sandbox stack now boots with a small generic chart of demo accounts so it is immediately explorable. The data lives only in an idempotent Liquibase changeset (INSERT ... ON CONFLICT DO NOTHING with fixed UUIDs), never in a shell script or a client. Gating: the ledger Liquibase contexts default to production, so prod and Helm deployments skip the demo changeset; the compose sandbox opts in with production,demo. The schema-test harness migrates with the production context so the schema integration tests mirror production and never load demo rows. Closes #235 --- docker-compose.yml | 1 + .../com/fincore/ledger/db/LedgerSchemaTestDb.kt | 3 ++- services/ledger/src/main/resources/application.yml | 1 + .../resources/db/changelog/db.changelog-master.yaml | 3 +++ .../db/changelog/demo/001-demo-accounts.sql | 12 ++++++++++++ 5 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 services/ledger/src/main/resources/db/changelog/demo/001-demo-accounts.sql diff --git a/docker-compose.yml b/docker-compose.yml index 8d83e14..d45e9b7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,6 +26,7 @@ services: SPRING_DATASOURCE_USERNAME: ledger SPRING_DATASOURCE_PASSWORD: ${POSTGRES_PASSWORD:-ledger} KEYCLOAK_ISSUER_URI: http://localhost/realms/fincore + SPRING_LIQUIBASE_CONTEXTS: production,demo payments: build: diff --git a/services/ledger/src/integrationTest/kotlin/com/fincore/ledger/db/LedgerSchemaTestDb.kt b/services/ledger/src/integrationTest/kotlin/com/fincore/ledger/db/LedgerSchemaTestDb.kt index 4b7f10c..a6eb917 100644 --- a/services/ledger/src/integrationTest/kotlin/com/fincore/ledger/db/LedgerSchemaTestDb.kt +++ b/services/ledger/src/integrationTest/kotlin/com/fincore/ledger/db/LedgerSchemaTestDb.kt @@ -19,6 +19,7 @@ import java.util.UUID internal const val IMAGE = "postgres:17-alpine" internal const val CHANGELOG = "db/changelog/db.changelog-master.yaml" +internal const val PRODUCTION_CONTEXT = "production" internal const val ACTOR = "test" internal const val CCY = "USD" internal const val ASSET = "ASSET" @@ -68,7 +69,7 @@ internal class LedgerSchemaTestDb( val connection = DriverManager.getConnection(postgres.jdbcUrl, postgres.username, postgres.password) val database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(JdbcConnection(connection)) Liquibase(CHANGELOG, ClassLoaderResourceAccessor(), database).use { liquibase -> - liquibase.update(Contexts(), LabelExpression()) + liquibase.update(Contexts(PRODUCTION_CONTEXT), LabelExpression()) } } diff --git a/services/ledger/src/main/resources/application.yml b/services/ledger/src/main/resources/application.yml index 981fc35..983f17e 100644 --- a/services/ledger/src/main/resources/application.yml +++ b/services/ledger/src/main/resources/application.yml @@ -11,6 +11,7 @@ spring: ddl-auto: none liquibase: change-log: classpath:db/changelog/db.changelog-master.yaml + contexts: ${SPRING_LIQUIBASE_CONTEXTS:production} security: oauth2: resourceserver: diff --git a/services/ledger/src/main/resources/db/changelog/db.changelog-master.yaml b/services/ledger/src/main/resources/db/changelog/db.changelog-master.yaml index 98beb66..92e51cc 100644 --- a/services/ledger/src/main/resources/db/changelog/db.changelog-master.yaml +++ b/services/ledger/src/main/resources/db/changelog/db.changelog-master.yaml @@ -40,3 +40,6 @@ databaseChangeLog: - include: file: v0.1/021-outbox-events-leased-at.sql relativeToChangelogFile: true + - include: + file: demo/001-demo-accounts.sql + relativeToChangelogFile: true diff --git a/services/ledger/src/main/resources/db/changelog/demo/001-demo-accounts.sql b/services/ledger/src/main/resources/db/changelog/demo/001-demo-accounts.sql new file mode 100644 index 0000000..6a154ab --- /dev/null +++ b/services/ledger/src/main/resources/db/changelog/demo/001-demo-accounts.sql @@ -0,0 +1,12 @@ +--liquibase formatted sql +-- SPDX-License-Identifier: BUSL-1.1 +-- SPDX-FileCopyrightText: 2026 FinCore Engine Authors + +--changeset fincore:demo-001-accounts context:demo dbms:postgresql +INSERT INTO ledger.accounts (id, name, type, currency, created_by, updated_by) VALUES + ('00000000-0000-0000-0000-000000000001', 'Customer Wallet USD', 'USER_WALLET', 'USD', 'demo-seed', 'demo-seed'), + ('00000000-0000-0000-0000-000000000002', 'Customer Wallet EUR', 'USER_WALLET', 'EUR', 'demo-seed', 'demo-seed'), + ('00000000-0000-0000-0000-000000000003', 'Platform Fee Income', 'FEE', 'USD', 'demo-seed', 'demo-seed'), + ('00000000-0000-0000-0000-000000000004', 'Settlement Reserve', 'RESERVE', 'USD', 'demo-seed', 'demo-seed'), + ('00000000-0000-0000-0000-000000000005', 'Suspense', 'SUSPENSE', 'USD', 'demo-seed', 'demo-seed') +ON CONFLICT (id) DO NOTHING;