pg_sql_triggers 1.2.0 → 1.3.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +144 -0
- data/COVERAGE.md +26 -19
- data/Goal.md +276 -155
- data/README.md +27 -1
- data/app/assets/javascripts/pg_sql_triggers/trigger_actions.js +50 -0
- data/app/controllers/concerns/pg_sql_triggers/error_handling.rb +56 -0
- data/app/controllers/concerns/pg_sql_triggers/kill_switch_protection.rb +66 -0
- data/app/controllers/concerns/pg_sql_triggers/permission_checking.rb +117 -0
- data/app/controllers/pg_sql_triggers/application_controller.rb +10 -62
- data/app/controllers/pg_sql_triggers/audit_logs_controller.rb +102 -0
- data/app/controllers/pg_sql_triggers/dashboard_controller.rb +4 -9
- data/app/controllers/pg_sql_triggers/tables_controller.rb +30 -4
- data/app/controllers/pg_sql_triggers/triggers_controller.rb +3 -21
- data/app/helpers/pg_sql_triggers/permissions_helper.rb +43 -0
- data/app/models/pg_sql_triggers/audit_log.rb +106 -0
- data/app/models/pg_sql_triggers/trigger_registry.rb +178 -9
- data/app/views/layouts/pg_sql_triggers/application.html.erb +26 -6
- data/app/views/pg_sql_triggers/audit_logs/index.html.erb +177 -0
- data/app/views/pg_sql_triggers/dashboard/index.html.erb +33 -8
- data/app/views/pg_sql_triggers/tables/index.html.erb +76 -3
- data/app/views/pg_sql_triggers/tables/show.html.erb +17 -4
- data/app/views/pg_sql_triggers/triggers/_drop_modal.html.erb +16 -7
- data/app/views/pg_sql_triggers/triggers/_re_execute_modal.html.erb +16 -7
- data/app/views/pg_sql_triggers/triggers/show.html.erb +26 -6
- data/config/routes.rb +2 -0
- data/db/migrate/20260103000001_create_pg_sql_triggers_audit_log.rb +28 -0
- data/docs/README.md +15 -5
- data/docs/api-reference.md +191 -0
- data/docs/audit-trail.md +413 -0
- data/docs/configuration.md +6 -6
- data/docs/permissions.md +369 -0
- data/docs/troubleshooting.md +486 -0
- data/docs/ui-guide.md +211 -0
- data/docs/web-ui.md +257 -34
- data/lib/pg_sql_triggers/errors.rb +245 -0
- data/lib/pg_sql_triggers/generator/service.rb +32 -0
- data/lib/pg_sql_triggers/permissions/checker.rb +9 -2
- data/lib/pg_sql_triggers/registry.rb +141 -8
- data/lib/pg_sql_triggers/sql/kill_switch.rb +33 -5
- data/lib/pg_sql_triggers/testing/function_tester.rb +2 -0
- data/lib/pg_sql_triggers/version.rb +1 -1
- data/lib/pg_sql_triggers.rb +3 -6
- metadata +29 -6
- data/docs/screenshots/.gitkeep +0 -1
- data/docs/screenshots/Generate Trigger.png +0 -0
- data/docs/screenshots/Triggers Page.png +0 -0
- data/docs/screenshots/kill error.png +0 -0
- data/docs/screenshots/kill modal for migration down.png +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6f8d9043692145293beaf91342280ca01702979a6e50190fd5930d8578170291
|
|
4
|
+
data.tar.gz: 18e9eaaa03de9932f9916bcc2110e9896a271c555a3b94f13348baf1e37c584c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8ed71a10f16385f318a4a596a444c07d2cb00a7d07119043c921cf43b1d2199db6d36cc30b5ea523bcbb527a817b97fbe7c507ac81a4cec3931f887c2a4606ca
|
|
7
|
+
data.tar.gz: af0162bab6005904e1649619e5a68e1c1f36733e4f8d34f0306c9a64af07356e9f19165dda1a60f19606b36b517ee1ad34224a50b479b02b0b8efd340175f1fc
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,150 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.3.0] - 2026-01-05
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- **Enhanced Console API**: Added missing drift query methods to Registry API for consistency
|
|
14
|
+
- `PgSqlTriggers::Registry.drifted` - Returns all drifted triggers
|
|
15
|
+
- `PgSqlTriggers::Registry.in_sync` - Returns all in-sync triggers
|
|
16
|
+
- `PgSqlTriggers::Registry.unknown_triggers` - Returns all unknown (external) triggers
|
|
17
|
+
- `PgSqlTriggers::Registry.dropped` - Returns all dropped triggers
|
|
18
|
+
- All console APIs now follow consistent naming conventions (query methods vs action methods)
|
|
19
|
+
|
|
20
|
+
- **Controller Concerns**: Extracted common controller functionality into reusable concerns
|
|
21
|
+
- `KillSwitchProtection` concern - Handles kill switch checking and confirmation helpers
|
|
22
|
+
- `PermissionChecking` concern - Handles permission checks and actor management
|
|
23
|
+
- `ErrorHandling` concern - Handles error formatting and flash message helpers
|
|
24
|
+
- All controllers now inherit from `ApplicationController` which includes these concerns
|
|
25
|
+
- Improved code organization and maintainability
|
|
26
|
+
|
|
27
|
+
- **YARD Documentation**: Comprehensive YARD documentation added to all public APIs
|
|
28
|
+
- `PgSqlTriggers::Registry` module - All public methods fully documented
|
|
29
|
+
- `PgSqlTriggers::TriggerRegistry` model - All public methods fully documented
|
|
30
|
+
- `PgSqlTriggers::Generator::Service` - All public class methods fully documented
|
|
31
|
+
- `PgSqlTriggers::SQL::Executor` - Already had documentation (verified)
|
|
32
|
+
- All documentation includes parameter types, return values, and examples
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
- **Complete UI Action Buttons**: All trigger operations now accessible via web UI
|
|
36
|
+
- Enable/Disable buttons in dashboard and table detail views
|
|
37
|
+
- Drop trigger button with confirmation modal (Admin permission required)
|
|
38
|
+
- Re-execute trigger button with drift diff display (Admin permission required)
|
|
39
|
+
- All buttons respect permission checks and show/hide based on user role
|
|
40
|
+
- Kill switch integration with confirmation modals for all actions
|
|
41
|
+
- Buttons styled with environment-aware colors (warning colors for production)
|
|
42
|
+
|
|
43
|
+
- **Enhanced Dashboard**:
|
|
44
|
+
- "Last Applied" column showing `installed_at` timestamps in human-readable format
|
|
45
|
+
- Tooltips with exact timestamps on hover
|
|
46
|
+
- Default sorting by `installed_at` (most recent first)
|
|
47
|
+
- Drop and Re-execute buttons in dashboard table (Admin only)
|
|
48
|
+
- Permission-aware button visibility throughout
|
|
49
|
+
|
|
50
|
+
- **Trigger Detail Page Enhancements**:
|
|
51
|
+
- Breadcrumb navigation (Dashboard → Tables → Table → Trigger)
|
|
52
|
+
- Enhanced `installed_at` display with relative time formatting
|
|
53
|
+
- `last_verified_at` timestamp display
|
|
54
|
+
- All action buttons (enable/disable/drop/re-execute) accessible from detail page
|
|
55
|
+
|
|
56
|
+
- **Comprehensive Audit Logging System**:
|
|
57
|
+
- New `pg_sql_triggers_audit_log` table for tracking all operations
|
|
58
|
+
- `AuditLog` model with logging methods (`log_success`, `log_failure`)
|
|
59
|
+
- Audit logging integrated into all trigger operations:
|
|
60
|
+
- `enable!` - logs success/failure with before/after state
|
|
61
|
+
- `disable!` - logs success/failure with before/after state
|
|
62
|
+
- `drop!` - logs success/failure with reason and state changes
|
|
63
|
+
- `re_execute!` - logs success/failure with drift diff information
|
|
64
|
+
- All operations track actor (who performed the action)
|
|
65
|
+
- Complete state capture (before/after) for all operations
|
|
66
|
+
- Error messages logged for failed operations
|
|
67
|
+
- Environment and confirmation text tracking
|
|
68
|
+
|
|
69
|
+
- **Enhanced Actor Tracking**:
|
|
70
|
+
- All trigger operations now accept `actor` parameter
|
|
71
|
+
- Console APIs updated to pass actor information
|
|
72
|
+
- UI controllers pass `current_actor` to all operations
|
|
73
|
+
- Actor information stored in audit logs for complete audit trail
|
|
74
|
+
|
|
75
|
+
- **Permissions Enforcement System**:
|
|
76
|
+
- Permission checks enforced across all controllers (Viewer, Operator, Admin)
|
|
77
|
+
- `PermissionsHelper` module for view-level permission checks
|
|
78
|
+
- Permission helper methods in `ApplicationController` for consistent authorization
|
|
79
|
+
- All UI buttons and actions respect permission levels
|
|
80
|
+
- Console APIs (`Registry.enable/disable/drop/re_execute`, `SQL::Executor.execute`) check permissions
|
|
81
|
+
- Permission errors raise `PermissionError` with clear messages
|
|
82
|
+
- Configurable permission checker via `permission_checker` configuration option
|
|
83
|
+
|
|
84
|
+
- **Enhanced Error Handling System**:
|
|
85
|
+
- Comprehensive error hierarchy with base `Error` class and specialized error types
|
|
86
|
+
- Error classes: `PermissionError`, `KillSwitchError`, `DriftError`, `ValidationError`, `ExecutionError`, `UnsafeMigrationError`, `NotFoundError`
|
|
87
|
+
- Error codes for programmatic handling (e.g., `PERMISSION_DENIED`, `KILL_SWITCH_ACTIVE`, `DRIFT_DETECTED`)
|
|
88
|
+
- Standardized error messages with recovery suggestions
|
|
89
|
+
- Enhanced error display in UI with user-friendly formatting
|
|
90
|
+
- Context information included in all errors for better debugging
|
|
91
|
+
- Error handling helpers in `ApplicationController` for consistent error formatting
|
|
92
|
+
|
|
93
|
+
- **Comprehensive Documentation**:
|
|
94
|
+
- New `ui-guide.md` - Quick start guide for web interface
|
|
95
|
+
- New `permissions.md` - Complete guide to configuring and using permissions
|
|
96
|
+
- New `audit-trail.md` - Guide to viewing and exporting audit logs
|
|
97
|
+
- New `troubleshooting.md` - Common issues and solutions with error code reference
|
|
98
|
+
- Updated documentation index with links to all new guides
|
|
99
|
+
|
|
100
|
+
- **Audit Log UI**:
|
|
101
|
+
- Web interface for viewing audit log entries (`/audit_logs`)
|
|
102
|
+
- Filterable by trigger name, operation, status, and environment
|
|
103
|
+
- Sortable by date (ascending/descending)
|
|
104
|
+
- Pagination support (default 50 entries per page, max 200)
|
|
105
|
+
- CSV export functionality with applied filters
|
|
106
|
+
- Comprehensive view showing operation details, actor information, status, and error messages
|
|
107
|
+
- Links to trigger detail pages from audit log entries
|
|
108
|
+
- Navigation menu integration
|
|
109
|
+
|
|
110
|
+
- **Enhanced Database Tables & Triggers Page**:
|
|
111
|
+
- Pagination support for tables list (default 20 per page, configurable up to 100)
|
|
112
|
+
- Filter functionality to view:
|
|
113
|
+
- All tables
|
|
114
|
+
- Tables with triggers only
|
|
115
|
+
- Tables without triggers only
|
|
116
|
+
- Enhanced statistics dashboard showing:
|
|
117
|
+
- Count of tables with triggers
|
|
118
|
+
- Count of tables without triggers
|
|
119
|
+
- Total tables count
|
|
120
|
+
- Filter controls with visual indicators for active filter
|
|
121
|
+
- Pagination controls preserve filter selection when navigating pages
|
|
122
|
+
- Context-aware empty state messages based on selected filter
|
|
123
|
+
|
|
124
|
+
### Changed
|
|
125
|
+
- **Code Organization**: Refactored `ApplicationController` to use concerns instead of inline methods
|
|
126
|
+
- Reduced code duplication across controllers
|
|
127
|
+
- Improved separation of concerns
|
|
128
|
+
- Better testability and maintainability
|
|
129
|
+
|
|
130
|
+
- **Service Object Patterns**: Standardized service object patterns across all service classes
|
|
131
|
+
- All service objects follow consistent class method patterns
|
|
132
|
+
- Consistent stateless service object conventions
|
|
133
|
+
|
|
134
|
+
- **Goal.md**: Updated to reflect actual implementation status
|
|
135
|
+
- Added technical notes documenting improvements
|
|
136
|
+
- Updated console API section with all implemented methods
|
|
137
|
+
- Documented code organization improvements
|
|
138
|
+
|
|
139
|
+
- Dashboard default sorting changed to `installed_at` (most recent first) instead of `created_at`
|
|
140
|
+
- Trigger detail page breadcrumbs improved navigation flow
|
|
141
|
+
- All trigger action buttons use consistent styling and permission checks
|
|
142
|
+
|
|
143
|
+
### Fixed
|
|
144
|
+
- Actor tracking now properly passed through all operation methods
|
|
145
|
+
- Improved error handling with audit log integration
|
|
146
|
+
|
|
147
|
+
### Security
|
|
148
|
+
- All operations now tracked in audit log for compliance and debugging
|
|
149
|
+
- Actor information captured for all operations (UI, Console, CLI)
|
|
150
|
+
- Complete state change tracking for audit trail
|
|
151
|
+
- Permission enforcement ensures only authorized users can perform operations
|
|
152
|
+
- Permission checks enforced at controller, API, and view levels
|
|
153
|
+
|
|
10
154
|
## [1.2.0] - 2026-01-02
|
|
11
155
|
|
|
12
156
|
### Added
|
data/COVERAGE.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Code Coverage Report
|
|
2
2
|
|
|
3
|
-
**Total Coverage: 95.
|
|
3
|
+
**Total Coverage: 95.99%**
|
|
4
4
|
|
|
5
|
-
Covered:
|
|
5
|
+
Covered: 2319 / 2416 lines
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -10,6 +10,9 @@ Covered: 2040 / 2140 lines
|
|
|
10
10
|
|
|
11
11
|
| File | Coverage | Covered Lines | Missed Lines | Total Lines |
|
|
12
12
|
|------|----------|---------------|--------------|-------------|
|
|
13
|
+
| `lib/pg_sql_triggers/drift.rb` | 100.0% ✅ | 13 | 0 | 13 |
|
|
14
|
+
| `lib/pg_sql_triggers/drift/db_queries.rb` | 100.0% ✅ | 24 | 0 | 24 |
|
|
15
|
+
| `lib/pg_sql_triggers/dsl.rb` | 100.0% ✅ | 9 | 0 | 9 |
|
|
13
16
|
| `lib/pg_sql_triggers/dsl/trigger_definition.rb` | 100.0% ✅ | 37 | 0 | 37 |
|
|
14
17
|
| `lib/pg_sql_triggers/generator.rb` | 100.0% ✅ | 4 | 0 | 4 |
|
|
15
18
|
| `lib/pg_sql_triggers/generator/form.rb` | 100.0% ✅ | 36 | 0 | 36 |
|
|
@@ -20,41 +23,45 @@ Covered: 2040 / 2140 lines
|
|
|
20
23
|
| `lib/pg_sql_triggers/migrator/pre_apply_diff_reporter.rb` | 100.0% ✅ | 75 | 0 | 75 |
|
|
21
24
|
| `lib/pg_sql_triggers/migrator/safety_validator.rb` | 100.0% ✅ | 110 | 0 | 110 |
|
|
22
25
|
| `lib/pg_sql_triggers/permissions.rb` | 100.0% ✅ | 11 | 0 | 11 |
|
|
23
|
-
| `lib/pg_sql_triggers/permissions/checker.rb` | 100.0% ✅ |
|
|
24
|
-
| `lib/pg_sql_triggers/registry.rb` | 100.0% ✅ | 41 | 0 | 41 |
|
|
26
|
+
| `lib/pg_sql_triggers/permissions/checker.rb` | 100.0% ✅ | 17 | 0 | 17 |
|
|
25
27
|
| `lib/pg_sql_triggers/registry/validator.rb` | 100.0% ✅ | 5 | 0 | 5 |
|
|
26
28
|
| `lib/pg_sql_triggers/sql/capsule.rb` | 100.0% ✅ | 28 | 0 | 28 |
|
|
27
29
|
| `lib/pg_sql_triggers/sql/executor.rb` | 100.0% ✅ | 63 | 0 | 63 |
|
|
28
30
|
| `lib/pg_sql_triggers/testing.rb` | 100.0% ✅ | 6 | 0 | 6 |
|
|
29
31
|
| `lib/pg_sql_triggers/testing/syntax_validator.rb` | 100.0% ✅ | 58 | 0 | 58 |
|
|
30
32
|
| `lib/pg_sql_triggers/testing/dry_run.rb` | 100.0% ✅ | 24 | 0 | 24 |
|
|
31
|
-
| `
|
|
33
|
+
| `app/models/pg_sql_triggers/audit_log.rb` | 100.0% ✅ | 28 | 0 | 28 |
|
|
34
|
+
| `app/models/pg_sql_triggers/trigger_registry.rb` | 100.0% ✅ | 176 | 0 | 176 |
|
|
35
|
+
| `app/controllers/concerns/pg_sql_triggers/error_handling.rb` | 100.0% ✅ | 19 | 0 | 19 |
|
|
36
|
+
| `app/controllers/concerns/pg_sql_triggers/kill_switch_protection.rb` | 100.0% ✅ | 17 | 0 | 17 |
|
|
32
37
|
| `app/models/pg_sql_triggers/application_record.rb` | 100.0% ✅ | 3 | 0 | 3 |
|
|
33
|
-
| `app/controllers/pg_sql_triggers/application_controller.rb` | 100.0% ✅ |
|
|
34
|
-
| `
|
|
35
|
-
| `
|
|
36
|
-
| `
|
|
37
|
-
| `lib/pg_sql_triggers/
|
|
38
|
+
| `app/controllers/pg_sql_triggers/application_controller.rb` | 100.0% ✅ | 13 | 0 | 13 |
|
|
39
|
+
| `app/helpers/pg_sql_triggers/permissions_helper.rb` | 100.0% ✅ | 16 | 0 | 16 |
|
|
40
|
+
| `app/controllers/pg_sql_triggers/dashboard_controller.rb` | 100.0% ✅ | 26 | 0 | 26 |
|
|
41
|
+
| `config/initializers/pg_sql_triggers.rb` | 100.0% ✅ | 10 | 0 | 10 |
|
|
42
|
+
| `lib/pg_sql_triggers/errors.rb` | 100.0% ✅ | 83 | 0 | 83 |
|
|
43
|
+
| `app/controllers/pg_sql_triggers/triggers_controller.rb` | 100.0% ✅ | 75 | 0 | 75 |
|
|
44
|
+
| `lib/pg_sql_triggers.rb` | 100.0% ✅ | 40 | 0 | 40 |
|
|
38
45
|
| `lib/pg_sql_triggers/migrator/pre_apply_comparator.rb` | 99.19% ✅ | 122 | 1 | 123 |
|
|
39
46
|
| `lib/pg_sql_triggers/drift/detector.rb` | 98.48% ✅ | 65 | 1 | 66 |
|
|
40
|
-
| `app/controllers/pg_sql_triggers/
|
|
41
|
-
| `app/controllers/pg_sql_triggers/
|
|
42
|
-
| `app/controllers/pg_sql_triggers/triggers_controller.rb` | 96.43% ✅ | 81 | 3 | 84 |
|
|
47
|
+
| `app/controllers/pg_sql_triggers/audit_logs_controller.rb` | 97.73% ✅ | 43 | 1 | 44 |
|
|
48
|
+
| `app/controllers/pg_sql_triggers/sql_capsules_controller.rb` | 97.14% ✅ | 68 | 2 | 70 |
|
|
43
49
|
| `lib/generators/pg_sql_triggers/trigger_migration_generator.rb` | 96.3% ✅ | 26 | 1 | 27 |
|
|
44
|
-
| `lib/pg_sql_triggers/sql/kill_switch.rb` | 96.
|
|
50
|
+
| `lib/pg_sql_triggers/sql/kill_switch.rb` | 96.04% ✅ | 97 | 4 | 101 |
|
|
45
51
|
| `lib/pg_sql_triggers/migrator.rb` | 95.42% ✅ | 125 | 6 | 131 |
|
|
46
52
|
| `lib/pg_sql_triggers/registry/manager.rb` | 95.08% ✅ | 58 | 3 | 61 |
|
|
47
|
-
| `app/controllers/pg_sql_triggers/tables_controller.rb` | 94.
|
|
53
|
+
| `app/controllers/pg_sql_triggers/tables_controller.rb` | 94.74% ✅ | 18 | 1 | 19 |
|
|
48
54
|
| `lib/pg_sql_triggers/database_introspection.rb` | 94.29% ✅ | 66 | 4 | 70 |
|
|
49
55
|
| `lib/pg_sql_triggers/drift/reporter.rb` | 94.12% ✅ | 96 | 6 | 102 |
|
|
50
56
|
| `lib/pg_sql_triggers/engine.rb` | 92.86% ✅ | 13 | 1 | 14 |
|
|
51
|
-
| `app/models/pg_sql_triggers/trigger_registry.rb` | 92.25% ✅ | 119 | 10 | 129 |
|
|
52
57
|
| `lib/pg_sql_triggers/testing/safe_executor.rb` | 91.89% ✅ | 34 | 3 | 37 |
|
|
58
|
+
| `lib/pg_sql_triggers/registry.rb` | 91.84% ✅ | 45 | 4 | 49 |
|
|
53
59
|
| `app/controllers/pg_sql_triggers/generator_controller.rb` | 91.49% ✅ | 86 | 8 | 94 |
|
|
54
60
|
| `lib/pg_sql_triggers/sql.rb` | 90.91% ✅ | 10 | 1 | 11 |
|
|
55
|
-
| `lib/pg_sql_triggers/testing/function_tester.rb` | 89.
|
|
56
|
-
| `app/controllers/pg_sql_triggers/
|
|
57
|
-
| `
|
|
61
|
+
| `lib/pg_sql_triggers/testing/function_tester.rb` | 89.71% ⚠️ | 61 | 7 | 68 |
|
|
62
|
+
| `app/controllers/concerns/pg_sql_triggers/permission_checking.rb` | 85.37% ⚠️ | 35 | 6 | 41 |
|
|
63
|
+
| `app/controllers/pg_sql_triggers/migrations_controller.rb` | 82.76% ⚠️ | 72 | 15 | 87 |
|
|
64
|
+
| `config/routes.rb` | 12.0% ❌ | 3 | 22 | 25 |
|
|
58
65
|
|
|
59
66
|
---
|
|
60
67
|
|