Skip to content

Commit 9dfec9f

Browse files
Initial commit: Yuniql PostgreSQL migrations with GitHub Actions
0 parents  commit 9dfec9f

File tree

19 files changed

+1781
-0
lines changed

19 files changed

+1781
-0
lines changed

.github/workflows/migrate.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# =============================================================================
2+
# Yuniql Database Migration Workflow
3+
# =============================================================================
4+
# Runs PostgreSQL migrations using Yuniql CLI.
5+
# Trigger: Push to main (migrations path) or manual dispatch.
6+
# =============================================================================
7+
8+
name: Database Migration
9+
10+
on:
11+
push:
12+
branches: [main]
13+
paths:
14+
- 'db/migrations/**'
15+
workflow_dispatch:
16+
inputs:
17+
debug:
18+
description: 'Enable debug output'
19+
required: false
20+
default: 'false'
21+
type: boolean
22+
23+
env:
24+
YUNIQL_VERSION: '1.3.15'
25+
MIGRATIONS_PATH: 'db/migrations'
26+
27+
jobs:
28+
migrate:
29+
runs-on: ubuntu-latest
30+
permissions:
31+
contents: read
32+
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
37+
- name: Setup .NET
38+
uses: actions/setup-dotnet@v4
39+
with:
40+
dotnet-version: |
41+
6.0.x
42+
8.0.x
43+
44+
- name: Install Yuniql CLI
45+
run: |
46+
dotnet tool install -g yuniql.cli --version "$YUNIQL_VERSION"
47+
echo "$HOME/.dotnet/tools" >> $GITHUB_PATH
48+
49+
- name: Verify Yuniql
50+
run: yuniql version
51+
52+
- name: Run Migrations
53+
env:
54+
DB_HOST: ${{ secrets.DB_HOST }}
55+
DB_USER: ${{ secrets.DB_USER }}
56+
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
57+
DB_NAME: ${{ secrets.DB_NAME }}
58+
run: |
59+
echo "=== Running Database Migrations ==="
60+
echo "Database: $DB_NAME"
61+
echo "Path: $MIGRATIONS_PATH"
62+
63+
CONNECTION_STRING="Host=${DB_HOST};Port=5432;Database=${DB_NAME};Username=${DB_USER};Password=${DB_PASSWORD};SSL Mode=Require;Trust Server Certificate=true"
64+
65+
# Build yuniql command
66+
YUNIQL_CMD="yuniql run \
67+
--platform postgresql \
68+
--connection-string \"$CONNECTION_STRING\" \
69+
--path \"$MIGRATIONS_PATH\" \
70+
--auto-create-db false"
71+
72+
# Add debug flag if requested
73+
if [ "${{ inputs.debug }}" = "true" ]; then
74+
YUNIQL_CMD="$YUNIQL_CMD --debug"
75+
fi
76+
77+
eval $YUNIQL_CMD
78+
79+
- name: Migration Complete
80+
run: echo "Database migrations completed successfully!"

.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# =============================================================================
2+
# Git Ignore for Yuniql Sample Project
3+
# =============================================================================
4+
5+
# Environment files (contain secrets!)
6+
.env
7+
*.env.local
8+
*.env.*.local
9+
10+
# Keep the example
11+
!.env.example
12+
13+
# OS files
14+
.DS_Store
15+
Thumbs.db
16+
17+
# IDE files
18+
.idea/
19+
.vscode/
20+
*.swp
21+
*.swo
22+
23+
# Logs
24+
*.log
25+
logs/
26+
27+
# Temporary files
28+
*.tmp
29+
*.temp
30+
tmp/
31+
temp/
32+
33+
# Yuniql trace files
34+
*.yuniql
35+
yuniql-trace-*.txt
36+
37+
# Docker
38+
.docker/

CHANGELOG.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
6+
7+
## [1.0.0] - 2026-01-27
8+
9+
### Added
10+
11+
- Initial project structure
12+
- Database migrations:
13+
- `v0.00`: Schema and initial tables (users, categories, products)
14+
- `v0.01`: Orders tables and sample data
15+
- `v0.02`: Audit logging and reporting views
16+
- GitHub Actions workflow for automated migrations
17+
- Local development scripts (bash and PowerShell)
18+
- Docker support with pre-built Yuniql image
19+
- Comprehensive documentation:
20+
- README.md with architecture diagrams
21+
- WALKTHROUGH.md for beginners
22+
- CONTRIBUTING.md for contributors
23+
24+
### Database Schema
25+
26+
Tables created:
27+
- `app.users` - User accounts
28+
- `app.categories` - Product categories (hierarchical)
29+
- `app.products` - Product catalog
30+
- `app.orders` - Customer orders
31+
- `app.order_items` - Order line items
32+
- `app.audit_log` - Change audit trail
33+
34+
Views created:
35+
- `app.v_product_inventory` - Stock status view
36+
- `app.v_order_summary` - Order summary view
37+
- `app.v_dashboard_stats` - Dashboard statistics
38+
39+
### CI/CD
40+
41+
- GitHub Actions workflow with:
42+
- Push trigger on `main` branch (migrations path)
43+
- Manual trigger with debug option
44+
- .NET 6.0 and 8.0 SDK support
45+
- Yuniql CLI v1.3.15

CONTRIBUTING.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Contributing Guide
2+
3+
Thank you for your interest in contributing to this project!
4+
5+
## How to Contribute
6+
7+
### Reporting Issues
8+
9+
1. Check if the issue already exists
10+
2. Create a new issue with:
11+
- Clear description of the problem
12+
- Steps to reproduce
13+
- Expected vs actual behavior
14+
- Environment details (OS, Docker version, PostgreSQL version)
15+
16+
### Submitting Changes
17+
18+
1. Fork the repository
19+
2. Create a feature branch:
20+
```bash
21+
git checkout -b feature/your-feature-name
22+
```
23+
3. Make your changes
24+
4. Test locally:
25+
```bash
26+
./scripts/run-local.sh
27+
```
28+
5. Commit with clear message:
29+
```bash
30+
git commit -m "feat: add new feature description"
31+
```
32+
6. Push and create a Pull Request
33+
34+
### Commit Message Format
35+
36+
We follow [Conventional Commits](https://www.conventionalcommits.org/):
37+
38+
```
39+
<type>(<scope>): <description>
40+
41+
Examples:
42+
feat(db): add user preferences table
43+
fix(workflow): correct .NET version
44+
docs: update README with troubleshooting
45+
```
46+
47+
Types: `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore`
48+
49+
## Development Setup
50+
51+
1. Clone the repository
52+
2. Copy environment template:
53+
```bash
54+
cp scripts/.env.example scripts/.env
55+
```
56+
3. Start local PostgreSQL:
57+
```bash
58+
docker run -d --name postgres-local \
59+
-e POSTGRES_USER=postgres \
60+
-e POSTGRES_PASSWORD=postgres \
61+
-e POSTGRES_DB=sample_db \
62+
-p 5432:5432 \
63+
postgres:15
64+
```
65+
4. Run migrations:
66+
```bash
67+
./scripts/run-local.sh
68+
```
69+
70+
## Code Style
71+
72+
### SQL Scripts
73+
74+
- Use `IF NOT EXISTS` / `IF EXISTS` for idempotency
75+
- Add comments for non-obvious logic
76+
- Use consistent naming (snake_case)
77+
- Include version and description header
78+
79+
```sql
80+
-- =============================================================================
81+
-- Version: v0.XX
82+
-- Description: Brief description of changes
83+
-- =============================================================================
84+
```
85+
86+
### Documentation
87+
88+
- Keep README.md focused and scannable
89+
- Use tables for structured information
90+
- Include code examples
91+
- Update CHANGELOG.md for significant changes
92+
93+
## Questions?
94+
95+
Open a discussion or issue on GitHub.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)