Skip to content

Add persistent Oracle database setup with multiple tables#2

Open
devin-ai-integration[bot] wants to merge 2 commits intodevelopfrom
devin/1767871382-persistent-oracle-setup
Open

Add persistent Oracle database setup with multiple tables#2
devin-ai-integration[bot] wants to merge 2 commits intodevelopfrom
devin/1767871382-persistent-oracle-setup

Conversation

@devin-ai-integration
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot commented Jan 8, 2026

Summary

This PR adds local development support for running the utPLSQL demo project with a persistent Oracle database instead of ephemeral CI/CD containers. The setup includes Docker Compose configuration with volume-based persistence and creates multiple tables demonstrating varying levels of database complexity.

Key additions:

  • Docker Compose configuration with persistent volume (oracle-data) mounted to /opt/oracle/oradata
  • Three tiers of table complexity: simple (lookup tables), medium (FK relationships, indexes, constraints), and complex (triggers, virtual columns, audit logging)
  • Shell scripts for database setup, full installation, and persistence verification
  • Comprehensive documentation in docs/PERSISTENT_DATABASE_SETUP.md

The complex tables include 5 triggers that handle automatic order total calculation, inventory tracking, customer audit logging, and timestamp updates.

Updates since last revision

Fixed SQL compatibility issues discovered during local testing:

  • Added SET DEFINE OFF to all SQL scripts to prevent & character in "Home & Garden" from being interpreted as a substitution variable prompt
  • Converted trg_update_order_total from a row-level trigger to a compound trigger to avoid ORA-04091 mutating table error when querying order_items during INSERT/UPDATE/DELETE
  • Removed redundant indexes on columns already indexed by UNIQUE constraints (email, product_code)

Local testing confirmed: tables install successfully, triggers fire correctly, order totals are calculated, inventory transactions are logged, and data persists across container restarts.

Review & Testing Checklist for Human

  • Verify compound trigger behavior - The trg_update_order_total compound trigger collects order IDs during row processing and updates totals in AFTER STATEMENT. Test with bulk inserts (e.g., INSERT INTO order_items SELECT ...) to verify totals calculate correctly for multiple rows in one statement.
  • Test data persistence - Run ./scripts/verify_persistence.sh or manually stop/start the container to confirm data survives restarts
  • Check inventory trigger edge cases - The trg_update_inventory is still a row-level trigger. Verify it handles product quantity updates correctly when multiple order items reference the same product in one transaction.

Recommended test plan:

  1. Run ./scripts/setup_persistent_db.sh and wait for database ready
  2. Run ./scripts/install_all.sh
  3. Connect via sqlplus ut3_demo/ut3_demo@//127.0.0.1:1521/XE and verify tables exist
  4. Query SELECT order_id, total_amount FROM orders; to verify order totals were calculated by triggers
  5. Run ./scripts/verify_persistence.sh to test persistence

Notes

  • Credentials are hardcoded (oracle for SYS, ut3_demo/ut3_demo for demo user) as this is a demo/development setup
  • The existing CI/CD workflows are unchanged; this adds parallel local development capability
  • SQL scripts were tested locally on Oracle XE 21c and work correctly on a fresh database

Link to Devin run: https://app.devin.ai/sessions/2510995b0b71448a8c395ef96d7c4fc5
Requested by: @SachetCognition

- Add Docker Compose configuration for persistent Oracle database with volume
- Create simple tables (categories, status_lookup) with basic constraints
- Create medium complexity tables (customers, products, orders) with foreign keys and indexes
- Create complex tables (order_items, audit_log, inventory_transactions) with triggers
- Add triggers for order totals, inventory tracking, and audit logging
- Add setup scripts for database initialization and installation
- Add verification script to test data persistence across restarts
- Add comprehensive documentation for the persistent database setup

Co-Authored-By: sachet.agarwal@windsurf.com <sachet.agarwal@windsurf.com>
@devin-ai-integration
Copy link
Copy Markdown
Author

Original prompt from sachet.agarwal
# Task: Set Up by_utPLSQL-demo-project with Persistent Database and Create Multiple Tables

## Background
The `SachetCognition/by_utPLSQL-demo-project` repository is a demonstration project for Oracle PL/SQL unit testing using the utPLSQL v3 testing framework with CI/CD integration. Currently, the repository uses **temporary Docker Oracle databases** (`gvenzl/oracle-xe:21-slim`) that are ephemeral and created only during CI/CD runs without persistent data.

## Objective
Modify the repository setup to:
1. Run the project locally with a persistent Oracle database (instead of temporary containers)
2. Create multiple tables with varying complexity
3. Ensure data persists across container restarts

## Current Setup Details

### Existing CI/CD Configuration
The repository has two CI/CD approaches:
- **GitHub Actions**: Located in `.github/workflows/build.yml` - uses Docker service containers with `gvenzl/oracle-xe:21-slim` image
- **Azure DevOps**: Uses templates in `.azure_templates/t-task-extend-create-docker-database.yml` that create temporary Oracle containers

### Required Dependencies
Before starting, ensure you have installed:
- Docker (for Oracle database containers)
- SQLcl (Oracle SQL command line tool)
- utPLSQL-cli (command line interface for testing)
- Oracle Database Docker image: `gvenzl/oracle-xe:21-slim`

## Tasks to Complete

### 1. Set Up Persistent Oracle Database
- Create a Docker Compose configuration or Docker run command that:
  - Uses the `gvenzl/oracle-xe:21-slim` image
  - Mounts a volume for data persistence (so data survives container restarts)
  - Exposes the Oracle database port (typically 1521)
  - Sets up appropriate environment variables for database credentials

### 2. Install utPLSQL Framework
- Install the utPLSQL v3 testing framework into the persistent database
- Reference the existing CI/CD workflows to understand the installation process

### 3. Create Multiple Tables with Varying Complexity
Create at least 3-5 tables with differen... (1419 chars truncated...)

@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

- Add SET DEFINE OFF to prevent & character substitution prompts
- Use compound trigger for trg_update_order_total to avoid mutating table error (ORA-04091)
- Remove redundant indexes on columns already indexed by UNIQUE constraints

Co-Authored-By: sachet.agarwal@windsurf.com <sachet.agarwal@windsurf.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants