database-model-generator 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,26 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MREwDwYDVQQDDAhkamJl
3
+ cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
4
+ MB4XDTE4MDMxODE1MjIwN1oXDTI4MDMxNTE1MjIwN1owPzERMA8GA1UEAwwIZGpi
5
+ ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
6
+ bTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALgfaroVM6CI06cxr0/h
7
+ A+j+pc8fgpRgBVmHFaFunq28GPC3IvW7Nvc3Y8SnAW7pP1EQIbhlwRIaQzJ93/yj
8
+ u95KpkP7tA9erypnV7dpzBkzNlX14ACaFD/6pHoXoe2ltBxk3CCyyzx70mTqJpph
9
+ 75IB03ni9a8yqn8pmse+s83bFJOAqddSj009sGPcQO+QOWiNxqYv1n5EHcvj2ebO
10
+ 6hN7YTmhx7aSia4qL/quc4DlIaGMWoAhvML7u1fmo53CYxkKskfN8MOecq2vfEmL
11
+ iLu+SsVVEAufMDDFMXMJlvDsviolUSGMSNRTujkyCcJoXKYYxZSNtIiyd9etI0X3
12
+ ctu0uhrFyrMZXCedutvXNjUolD5r9KGBFSWH1R9u2I3n3SAyFF2yzv/7idQHLJJq
13
+ 74BMnx0FIq6fCpu5slAipvxZ3ZkZpEXZFr3cIBtO1gFvQWW7E/Y3ijliWJS1GQFq
14
+ 058qERadHGu1yu1dojmFRo6W2KZvY9al2yIlbkpDrD5MYQIDAQABo3cwdTAJBgNV
15
+ HRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUFZsMapgzJimzsbaBG2Tm8j5e
16
+ AzgwHQYDVR0RBBYwFIESZGpiZXJnOTZAZ21haWwuY29tMB0GA1UdEgQWMBSBEmRq
17
+ YmVyZzk2QGdtYWlsLmNvbTANBgkqhkiG9w0BAQsFAAOCAYEAW2tnYixXQtKxgGXq
18
+ /3iSWG2bLwvxS4go3srO+aRXZHrFUMlJ5W0mCxl03aazxxKTsVVpZD8QZxvK91OQ
19
+ h9zr9JBYqCLcCVbr8SkmYCi/laxIZxsNE5YI8cC8vvlLI7AMgSfPSnn/Epq1GjGY
20
+ 6L1iRcEDtanGCIvjqlCXO9+BmsnCfEVehqZkQHeYczA03tpOWb6pon2wzvMKSsKH
21
+ ks0ApVdstSLz1kzzAqem/uHdG9FyXdbTAwH1G4ZPv69sQAFAOCgAqYmdnzedsQtE
22
+ 1LQfaQrx0twO+CZJPcRLEESjq8ScQxWRRkfuh2VeR7cEU7L7KqT10mtUwrvw7APf
23
+ DYoeCY9KyjIBjQXfbj2ke5u1hZj94Fsq9FfbEQg8ygCgwThnmkTrrKEiMSs3alYR
24
+ ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
25
+ WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
26
+ -----END CERTIFICATE-----
@@ -0,0 +1,31 @@
1
+ require 'rubygems'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'database-model-generator'
5
+ spec.version = '0.6.0'
6
+ spec.author = 'Daniel J. Berger'
7
+ spec.license = 'Apache-2.0'
8
+ spec.email = 'djberg96@gmail.com'
9
+ spec.homepage = 'http://www.github.com/djberg96/database-model-generator'
10
+ spec.summary = 'A Ruby library for generating Rails AR models from existing tables.'
11
+ spec.test_files = Dir['spec/**/*.rb']
12
+ spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
13
+ spec.cert_chain = spec.cert_chain = ['certs/djberg96_pub.pem']
14
+
15
+ spec.executables = 'dmg'
16
+
17
+ spec.add_dependency('getopt', '~> 1.6')
18
+
19
+ # I do not require vendor-specific gems because I do not know which vendor
20
+ # you may or may not be using. However, I've added them as development
21
+ # dependencies for testing, and as a clue for you the reader.
22
+ spec.add_development_dependency('rspec', '~> 3.12')
23
+ spec.add_development_dependency('ruby-oci8', '~> 2.2')
24
+ spec.add_development_dependency('tiny_tds', '~> 3.2.1')
25
+
26
+ spec.description = <<-EOF
27
+ The database-model-generator library allows you to generate an ActiveRecord
28
+ model from an existing Oracle table or view, as well as automatically
29
+ generate a baseline test file for test-unit or minitest.
30
+ EOF
31
+ end
data/docker/README.md ADDED
@@ -0,0 +1,238 @@
1
+ # Docker Support for Database Model Generator
2
+
3
+ This directory contains Docker configurations for testing the Database Model Generator with different database systems.
4
+
5
+ ## Directory Structure
6
+
7
+ - `oracle/` - Oracle database Docker configurations and documentation
8
+ - `sqlserver/` - SQL Server database Docker configurations and documentation
9
+
10
+ ## Quick Start
11
+
12
+ ### Oracle
13
+ ```bash
14
+ cd oracle
15
+ docker-compose up
16
+ ```
17
+
18
+ ### SQL Server
19
+ ```bash
20
+ cd sqlserver
21
+ docker-compose up
22
+ ```
23
+
24
+ ## Database-Specific Documentation
25
+
26
+ - [Oracle Docker Setup](oracle/README.md)
27
+ - [SQL Server Docker Setup](sqlserver/DOCKER.md)
28
+ - [SQL Server Testing Guide](sqlserver/TESTING.md)
29
+ - [SQL Server Support Documentation](sqlserver/SUPPORT.md)
30
+
31
+ ## Requirements
32
+
33
+ - Docker
34
+ - Docker Compose
35
+ - Ruby 3.0+ (for local development)
36
+
37
+ ## Testing
38
+
39
+ Each database type includes its own testing scripts and documentation. See the individual directories for specific instructions.
40
+
41
+ ## Quick Start
42
+
43
+ ### Option 1: Simple Test (Recommended)
44
+
45
+ Run the simple test script that handles everything automatically:
46
+
47
+ ```bash
48
+ ./test_sqlserver_simple.sh
49
+ ```
50
+
51
+ This script will:
52
+ - Start a SQL Server container
53
+ - Create a test database with sample tables
54
+ - Test the Database Model Generator
55
+ - Show generated models and tests
56
+ - Clean up when done
57
+
58
+ ### Option 2: Docker Compose (Advanced)
59
+
60
+ Use Docker Compose for more control:
61
+
62
+ ```bash
63
+ # Start SQL Server
64
+ docker-compose -f docker-compose.sqlserver.yml up -d sqlserver
65
+
66
+ # Wait for SQL Server to be ready (1-2 minutes)
67
+ # Then run tests
68
+ docker-compose -f docker-compose.sqlserver.yml up omg_test
69
+
70
+ # Clean up
71
+ docker-compose -f docker-compose.sqlserver.yml down -v
72
+ ```
73
+
74
+ ### Option 3: Manual Docker Setup
75
+
76
+ ```bash
77
+ # Start SQL Server container
78
+ docker run -d \
79
+ --name sqlserver_test \
80
+ -e "ACCEPT_EULA=Y" \
81
+ -e "SA_PASSWORD=YourStrong!Passw0rd" \
82
+ -e "MSSQL_PID=Express" \
83
+ -p 1433:1433 \
84
+ mcr.microsoft.com/mssql/server:2022-latest
85
+
86
+ # Wait for startup (about 1 minute)
87
+ sleep 60
88
+
89
+ # Create test database
90
+ docker exec sqlserver_test /opt/mssql-tools/bin/sqlcmd \
91
+ -S localhost -U sa -P YourStrong!Passw0rd \
92
+ -Q "CREATE DATABASE test_db"
93
+
94
+ # Test the generator
95
+ ruby bin/omg -T sqlserver -s localhost -P 1433 -d test_db \
96
+ -u sa -p 'YourStrong!Passw0rd' -t INFORMATION_SCHEMA.TABLES -x rspec
97
+
98
+ # Clean up
99
+ docker stop sqlserver_test && docker rm sqlserver_test
100
+ ```
101
+
102
+ ## Database Schema
103
+
104
+ The test setup creates a sample database with the following tables:
105
+
106
+ ### users
107
+ - id (INT, PRIMARY KEY, IDENTITY)
108
+ - username (NVARCHAR(50), UNIQUE)
109
+ - email (NVARCHAR(100), UNIQUE)
110
+ - first_name, last_name (NVARCHAR(50))
111
+ - age (INT)
112
+ - salary (DECIMAL(10,2))
113
+ - is_active (BIT)
114
+ - status (NVARCHAR(20))
115
+ - created_at, updated_at (DATETIME2)
116
+ - bio (NVARCHAR(MAX))
117
+
118
+ ### posts
119
+ - id (INT, PRIMARY KEY, IDENTITY)
120
+ - user_id (INT, FOREIGN KEY โ†’ users.id)
121
+ - title (NVARCHAR(200))
122
+ - content (NVARCHAR(MAX))
123
+ - status (NVARCHAR(20))
124
+ - published_at (DATETIME2)
125
+ - created_at (DATETIME2)
126
+ - view_count (INT)
127
+
128
+ ### categories
129
+ - id (INT, PRIMARY KEY, IDENTITY)
130
+ - name (NVARCHAR(100), UNIQUE)
131
+ - description (NVARCHAR(500))
132
+ - slug (NVARCHAR(100), UNIQUE)
133
+ - parent_id (INT, FOREIGN KEY โ†’ categories.id)
134
+ - is_active (BIT)
135
+ - created_at (DATETIME2)
136
+
137
+ ### post_categories (Junction table)
138
+ - id (INT, PRIMARY KEY, IDENTITY)
139
+ - post_id (INT, FOREIGN KEY โ†’ posts.id)
140
+ - category_id (INT, FOREIGN KEY โ†’ categories.id)
141
+ - created_at (DATETIME2)
142
+
143
+ ### comments
144
+ - id (INT, PRIMARY KEY, IDENTITY)
145
+ - post_id (INT, FOREIGN KEY โ†’ posts.id)
146
+ - user_id (INT, FOREIGN KEY โ†’ users.id)
147
+ - content (NVARCHAR(MAX))
148
+ - status (NVARCHAR(20))
149
+ - created_at, updated_at (DATETIME2)
150
+
151
+ ## Connection Details
152
+
153
+ When testing manually:
154
+ - **Server**: localhost:1433
155
+ - **Username**: sa
156
+ - **Password**: YourStrong!Passw0rd
157
+ - **Database**: test_db
158
+
159
+ ## Prerequisites
160
+
161
+ - Docker installed and running
162
+ - Ruby with bundler
163
+ - `tiny_tds` gem (automatically installed by test scripts)
164
+
165
+ ### Installing tiny_tds
166
+
167
+ If you need to install the `tiny_tds` gem manually:
168
+
169
+ **Ubuntu/Debian:**
170
+ ```bash
171
+ sudo apt-get install build-essential freetds-dev
172
+ gem install tiny_tds
173
+ ```
174
+
175
+ **macOS:**
176
+ ```bash
177
+ brew install freetds
178
+ gem install tiny_tds
179
+ ```
180
+
181
+ **Windows:**
182
+ ```bash
183
+ gem install tiny_tds
184
+ ```
185
+
186
+ ## Test Features
187
+
188
+ The test scripts verify:
189
+
190
+ 1. **Model Generation**: Creates ActiveRecord models from SQL Server tables
191
+ 2. **Test Generation**: Creates RSpec, Minitest, or TestUnit test files
192
+ 3. **Index Recommendations**: Analyzes tables and suggests performance indexes
193
+ 4. **Auto-detection**: Automatically detects SQL Server when server parameter is provided
194
+ 5. **Foreign Key Relationships**: Maps foreign keys to ActiveRecord associations
195
+ 6. **Data Type Mapping**: Correctly maps SQL Server types to Ruby/Rails validations
196
+
197
+ ## Example Usage
198
+
199
+ ```bash
200
+ # Generate a User model with RSpec tests
201
+ ruby bin/omg -T sqlserver -s localhost -P 1433 -d test_db \
202
+ -u sa -p 'YourStrong!Passw0rd' -t users -x rspec
203
+
204
+ # Show index recommendations for posts table
205
+ ruby bin/omg -T sqlserver -s localhost -P 1433 -d test_db \
206
+ -u sa -p 'YourStrong!Passw0rd' -t posts -i
207
+
208
+ # Auto-detect database type (SQL Server)
209
+ ruby bin/omg -s localhost -d test_db -u sa -p 'YourStrong!Passw0rd' -t categories
210
+ ```
211
+
212
+ ## Troubleshooting
213
+
214
+ ### SQL Server not starting
215
+ - Wait longer (SQL Server can take 2-3 minutes to fully start)
216
+ - Check Docker logs: `docker logs sqlserver_test`
217
+ - Ensure port 1433 is not in use
218
+
219
+ ### Connection errors
220
+ - Verify the password meets SQL Server requirements (8+ chars, mixed case, numbers, symbols)
221
+ - Check firewall settings
222
+ - Ensure SQL Server container is fully started
223
+
224
+ ### tiny_tds installation issues
225
+ - Install system dependencies (freetds-dev on Linux, freetds on macOS)
226
+ - Check Ruby version compatibility
227
+ - Try using the system package manager version
228
+
229
+ ## Files
230
+
231
+ - `docker/sqlserver/Dockerfile` - SQL Server container setup
232
+ - `docker/sqlserver/init-db.sql` - Database initialization script
233
+ - `docker/sqlserver/setup-db.sh` - Database setup automation
234
+ - `docker/test/Dockerfile` - Test runner container
235
+ - `docker/test/run_tests.sh` - Comprehensive test suite
236
+ - `docker-compose.sqlserver.yml` - Docker Compose configuration
237
+ - `test_sqlserver_simple.sh` - Simple all-in-one test script
238
+ - `test_sqlserver_docker.sh` - Advanced Docker test script
@@ -0,0 +1,87 @@
1
+ # Dockerfile for testing oracle-model-generator library
2
+ FROM ruby:3.1-bullseye
3
+
4
+ # Install system dependencies
5
+ RUN apt-get update && apt-get install -y \
6
+ wget \
7
+ unzip \
8
+ libaio1 \
9
+ libaio-dev \
10
+ build-essential \
11
+ && rm -rf /var/lib/apt/lists/*
12
+
13
+ # Download and install Oracle Instant Client
14
+ WORKDIR /opt/oracle
15
+ RUN wget https://download.oracle.com/otn_software/linux/instantclient/1913000/instantclient-basic-linux.x64-19.13.0.0.0dbru.zip && \
16
+ wget https://download.oracle.com/otn_software/linux/instantclient/1913000/instantclient-sdk-linux.x64-19.13.0.0.0dbru.zip && \
17
+ unzip instantclient-basic-linux.x64-19.13.0.0.0dbru.zip && \
18
+ unzip instantclient-sdk-linux.x64-19.13.0.0.0dbru.zip && \
19
+ rm -f *.zip
20
+
21
+ # Set Oracle environment variables
22
+ ENV ORACLE_HOME=/opt/oracle/instantclient_19_13
23
+ ENV LD_LIBRARY_PATH=$ORACLE_HOME
24
+ ENV PATH=$ORACLE_HOME:$PATH
25
+
26
+ # Create symbolic links for OCI8 compilation
27
+ RUN cd $ORACLE_HOME && \
28
+ ln -sf libclntsh.so.19.1 libclntsh.so && \
29
+ ln -sf libocci.so.19.1 libocci.so
30
+
31
+ # Set working directory for the application
32
+ WORKDIR /app
33
+
34
+ # Copy gemspec and Gemfile first for better Docker layer caching
35
+ COPY oracle-model-generator.gemspec Gemfile ./
36
+
37
+ # Install Ruby dependencies
38
+ RUN bundle config set --local deployment false && \
39
+ bundle install --verbose
40
+
41
+ # Copy the rest of the application
42
+ COPY . .
43
+
44
+ # Create a script to run tests with Oracle connection
45
+ RUN echo '#!/bin/bash\n\
46
+ echo "Starting Oracle Model Generator test environment..."\n\
47
+ echo ""\n\
48
+ echo "This Docker container includes:"\n\
49
+ echo "- Ruby $(ruby --version)"\n\
50
+ echo "- Oracle Instant Client 19.13"\n\
51
+ echo "- All required gems for oracle-model-generator"\n\
52
+ echo ""\n\
53
+ echo "To run tests, you need to:"\n\
54
+ echo "1. Have an Oracle database running (Oracle XE recommended)"\n\
55
+ echo "2. Ensure the '\''hr'\'' schema is available with sample data"\n\
56
+ echo "3. Update connection parameters in test file if needed"\n\
57
+ echo ""\n\
58
+ echo "Available commands:"\n\
59
+ echo " bundle exec ruby test/test_oracle_model_generator.rb # Run tests"\n\
60
+ echo " bundle exec ruby -Ilib bin/omg --help # Run CLI tool"\n\
61
+ echo " irb -I lib -r oracle/model/generator # Interactive Ruby"\n\
62
+ echo ""\n\
63
+ echo "Current Oracle environment:"\n\
64
+ echo " ORACLE_HOME: $ORACLE_HOME"\n\
65
+ echo " LD_LIBRARY_PATH: $LD_LIBRARY_PATH"\n\
66
+ echo ""\n\
67
+ \n\
68
+ # Check if arguments were passed to run specific commands\n\
69
+ if [ $# -eq 0 ]; then\n\
70
+ echo "No command specified. Starting bash shell..."\n\
71
+ exec /bin/bash\n\
72
+ else\n\
73
+ exec "$@"\n\
74
+ fi' > /app/run_tests.sh
75
+
76
+ RUN chmod +x /app/run_tests.sh
77
+
78
+ # Expose any ports that might be needed (none for this library)
79
+ # EXPOSE 8080
80
+
81
+ # Set the default command
82
+ CMD ["/app/run_tests.sh"]
83
+
84
+ # Add some helpful labels
85
+ LABEL maintainer="Testing Environment for oracle-model-generator"
86
+ LABEL description="Docker image for testing the oracle-model-generator Ruby library with Oracle Instant Client"
87
+ LABEL version="1.0"
@@ -0,0 +1,140 @@
1
+ # Docker Testing Environment for Oracle Model Generator
2
+
3
+ This directory contains a complete Docker setup for testing the oracle-model-generator Ruby library with Oracle database connectivity.
4
+
5
+ ## Files Created
6
+
7
+ ### Docker Configuration
8
+ - `Dockerfile` - Production-ready Docker image with Oracle connectivity
9
+ - `docker-compose.yml` - Complete testing environment with Oracle XE database
10
+ - `.dockerignore` - Optimizes Docker build context
11
+
12
+ ### Testing Files
13
+ - `test/test_oracle_model_generator_docker.rb` - Docker-optimized test suite
14
+ - `DOCKER.md` - Detailed documentation and troubleshooting guide
15
+
16
+ ## Quick Start
17
+
18
+ ### Option 1: Full Testing Environment (with Oracle Database)
19
+
20
+ 1. **Start the complete environment:**
21
+ ```bash
22
+ docker-compose up -d
23
+ ```
24
+
25
+ 2. **Wait for Oracle database to be ready:**
26
+ ```bash
27
+ docker-compose logs -f oracle-db
28
+ # Wait for "DATABASE IS READY TO USE!" message
29
+ ```
30
+
31
+ 3. **Run tests:**
32
+ ```bash
33
+ docker-compose exec app ruby test/test_oracle_model_generator_docker.rb
34
+ ```
35
+
36
+ 4. **Interactive shell for development:**
37
+ ```bash
38
+ docker-compose exec app bash
39
+ ```
40
+
41
+ ### Option 2: Build and Test Application Only
42
+
43
+ 1. **Build the image:**
44
+ ```bash
45
+ docker build -t oracle-model-generator .
46
+ ```
47
+
48
+ 2. **Run with external database:**
49
+ ```bash
50
+ docker run -e ORACLE_HOST=your-db-host \
51
+ -e ORACLE_PORT=1521 \
52
+ -e ORACLE_SID=your-sid \
53
+ -e ORACLE_USER=your-user \
54
+ -e ORACLE_PASSWORD=your-password \
55
+ oracle-model-generator
56
+ ```
57
+
58
+ ## Environment Variables
59
+
60
+ The Docker environment supports these variables for database connection:
61
+
62
+ - `ORACLE_HOST` - Database hostname (default: oracle-db)
63
+ - `ORACLE_PORT` - Database port (default: 1521)
64
+ - `ORACLE_SID` - Database SID (default: XE)
65
+ - `ORACLE_USER` - Database username (default: hr)
66
+ - `ORACLE_PASSWORD` - Database password (default: oracle)
67
+
68
+ ## What's Included
69
+
70
+ ### Oracle Instant Client 19.13
71
+ - Full Oracle connectivity libraries
72
+ - Properly configured environment variables
73
+ - Native compilation support for ruby-oci8
74
+
75
+ ### Ruby Environment
76
+ - Ruby 3.1 with bundler
77
+ - All project dependencies installed
78
+ - Optimized for Oracle development
79
+
80
+ ### Test Database (via docker-compose)
81
+ - Oracle Express Edition 21c
82
+ - Pre-configured HR sample schema
83
+ - Ready-to-use test data
84
+
85
+ ## Development Workflow
86
+
87
+ 1. **Make code changes** in your local workspace
88
+ 2. **Rebuild the image:** `docker-compose build app`
89
+ 3. **Run tests:** `docker-compose exec app ruby test/test_oracle_model_generator_docker.rb`
90
+ 4. **Debug interactively:** `docker-compose exec app bash`
91
+
92
+ ## Troubleshooting
93
+
94
+ ### Common Issues
95
+
96
+ 1. **ruby-oci8 compilation errors:**
97
+ - Ensure Oracle Instant Client is properly installed
98
+ - Check environment variables are set correctly
99
+ - Verify build-essential package is installed
100
+
101
+ 2. **Database connection failures:**
102
+ - Wait for Oracle container to fully initialize
103
+ - Check network connectivity between containers
104
+ - Verify database credentials
105
+
106
+ 3. **Permission issues:**
107
+ - Ensure Docker has necessary permissions
108
+ - Check file ownership in mounted volumes
109
+
110
+ ### Debugging Commands
111
+
112
+ ```bash
113
+ # Check Oracle client installation
114
+ docker-compose exec app ls -la /opt/oracle/instantclient_19_13/
115
+
116
+ # Test database connectivity
117
+ docker-compose exec app sqlplus hr/oracle@oracle-db:1521/XE
118
+
119
+ # Check environment variables
120
+ docker-compose exec app env | grep ORACLE
121
+
122
+ # View bundler gem installation
123
+ docker-compose exec app bundle list
124
+ ```
125
+
126
+ ## Performance Notes
127
+
128
+ - Initial build takes 10-15 minutes (Oracle client compilation)
129
+ - Subsequent builds use Docker layer caching
130
+ - Oracle database initialization takes 2-3 minutes
131
+ - Consider using volumes for persistent development
132
+
133
+ ## Security Considerations
134
+
135
+ - Default passwords are for development only
136
+ - Use Docker secrets for production deployments
137
+ - Limit network exposure in production environments
138
+ - Regular security updates for base images
139
+
140
+ For detailed information, see `DOCKER.md`.
@@ -0,0 +1,41 @@
1
+ services:
2
+ # Oracle Express Edition database for testing
3
+ oracle-db:
4
+ image: gvenzl/oracle-xe:21-slim
5
+ environment:
6
+ - ORACLE_PASSWORD=oracle
7
+ - APP_USER=hr
8
+ - APP_USER_PASSWORD=hr
9
+ ports:
10
+ - "1521:1521"
11
+ volumes:
12
+ - oracle_data:/opt/oracle/oradata
13
+ shm_size: 1g
14
+ healthcheck:
15
+ test: ["CMD", "healthcheck.sh"]
16
+ interval: 30s
17
+ timeout: 10s
18
+ retries: 5
19
+ start_period: 60s
20
+
21
+ # Oracle Model Generator testing environment
22
+ oracle-model-generator:
23
+ build: .
24
+ depends_on:
25
+ oracle-db:
26
+ condition: service_healthy
27
+ environment:
28
+ - ORACLE_HOST=oracle-db
29
+ - ORACLE_PORT=1521
30
+ - ORACLE_SID=freepdb1
31
+ - ORACLE_USER=hr
32
+ - ORACLE_PASSWORD=hr
33
+ volumes:
34
+ - .:/app
35
+ working_dir: /app
36
+ stdin_open: true
37
+ tty: true
38
+ command: ["rake"] # This will run tests with automatic setup
39
+
40
+ volumes:
41
+ oracle_data:
@@ -0,0 +1,45 @@
1
+ #!/bin/bash
2
+
3
+ echo "=== Oracle Model Generator Test ==="
4
+ echo
5
+
6
+ # Check if Docker is available
7
+ if ! docker --version > /dev/null 2>&1; then
8
+ echo "โŒ Docker is not available"
9
+ exit 1
10
+ fi
11
+
12
+ echo "โœ… Docker is available"
13
+
14
+ # Start Oracle database
15
+ echo "๐Ÿš€ Starting Oracle database with Docker Compose..."
16
+ docker-compose up -d
17
+
18
+ echo "โณ Waiting for Oracle to be ready..."
19
+ # Wait for Oracle to be healthy
20
+ timeout=300
21
+ elapsed=0
22
+ while [ $elapsed -lt $timeout ]; do
23
+ if docker-compose logs oracle-db 2>/dev/null | grep -q "DATABASE IS READY TO USE"; then
24
+ echo "โœ… Oracle database is ready"
25
+ break
26
+ fi
27
+ sleep 5
28
+ elapsed=$((elapsed + 5))
29
+ echo " Still waiting... (${elapsed}s/${timeout}s)"
30
+ done
31
+
32
+ if [ $elapsed -ge $timeout ]; then
33
+ echo "โŒ Oracle database failed to start within ${timeout} seconds"
34
+ docker-compose logs oracle-db
35
+ exit 1
36
+ fi
37
+
38
+ echo "๐Ÿงช Oracle database is ready for testing"
39
+ echo "๐Ÿ“‹ You can now run Oracle Model Generator tests"
40
+ echo
41
+ echo "To stop the database:"
42
+ echo " docker-compose down"
43
+ echo
44
+ echo "To connect to Oracle:"
45
+ echo " docker-compose exec oracle-db sqlplus hr/oracle@//localhost:1521/XEPDB1"