pg_sql_triggers 1.0.0 → 1.1.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/.erb_lint.yml +47 -0
- data/.rubocop.yml +4 -1
- data/CHANGELOG.md +112 -1
- data/COVERAGE.md +58 -0
- data/Goal.md +450 -123
- data/README.md +53 -215
- data/app/controllers/pg_sql_triggers/application_controller.rb +46 -0
- data/app/controllers/pg_sql_triggers/dashboard_controller.rb +4 -1
- data/app/controllers/pg_sql_triggers/generator_controller.rb +76 -8
- data/app/controllers/pg_sql_triggers/migrations_controller.rb +18 -0
- data/app/models/pg_sql_triggers/trigger_registry.rb +93 -12
- data/app/views/layouts/pg_sql_triggers/application.html.erb +34 -1
- data/app/views/pg_sql_triggers/dashboard/index.html.erb +70 -30
- data/app/views/pg_sql_triggers/generator/new.html.erb +22 -4
- data/app/views/pg_sql_triggers/generator/preview.html.erb +244 -16
- data/app/views/pg_sql_triggers/shared/_confirmation_modal.html.erb +221 -0
- data/app/views/pg_sql_triggers/shared/_kill_switch_status.html.erb +40 -0
- data/app/views/pg_sql_triggers/tables/index.html.erb +0 -2
- data/app/views/pg_sql_triggers/tables/show.html.erb +3 -4
- data/config/initializers/pg_sql_triggers.rb +69 -0
- data/db/migrate/20251222000001_create_pg_sql_triggers_tables.rb +3 -1
- data/db/migrate/20251229071916_add_timing_to_pg_sql_triggers_registry.rb +8 -0
- data/docs/README.md +66 -0
- data/docs/api-reference.md +681 -0
- data/docs/configuration.md +541 -0
- data/docs/getting-started.md +135 -0
- data/docs/kill-switch.md +586 -0
- data/docs/screenshots/.gitkeep +1 -0
- 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
- data/docs/usage-guide.md +493 -0
- data/docs/web-ui.md +353 -0
- data/lib/generators/pg_sql_triggers/templates/create_pg_sql_triggers_tables.rb +3 -1
- data/lib/generators/pg_sql_triggers/templates/initializer.rb +44 -2
- data/lib/pg_sql_triggers/drift/db_queries.rb +116 -0
- data/lib/pg_sql_triggers/drift/detector.rb +187 -0
- data/lib/pg_sql_triggers/drift/reporter.rb +179 -0
- data/lib/pg_sql_triggers/drift.rb +14 -11
- data/lib/pg_sql_triggers/dsl/trigger_definition.rb +15 -1
- data/lib/pg_sql_triggers/generator/form.rb +3 -1
- data/lib/pg_sql_triggers/generator/service.rb +82 -26
- data/lib/pg_sql_triggers/migration.rb +1 -1
- data/lib/pg_sql_triggers/migrator/pre_apply_comparator.rb +344 -0
- data/lib/pg_sql_triggers/migrator/pre_apply_diff_reporter.rb +143 -0
- data/lib/pg_sql_triggers/migrator/safety_validator.rb +258 -0
- data/lib/pg_sql_triggers/migrator.rb +85 -3
- data/lib/pg_sql_triggers/registry/manager.rb +100 -13
- data/lib/pg_sql_triggers/sql/kill_switch.rb +300 -0
- data/lib/pg_sql_triggers/testing/dry_run.rb +5 -7
- data/lib/pg_sql_triggers/testing/function_tester.rb +66 -24
- data/lib/pg_sql_triggers/testing/safe_executor.rb +23 -11
- data/lib/pg_sql_triggers/testing/syntax_validator.rb +24 -1
- data/lib/pg_sql_triggers/version.rb +1 -1
- data/lib/pg_sql_triggers.rb +24 -0
- data/lib/tasks/trigger_migrations.rake +33 -0
- data/scripts/generate_coverage_report.rb +129 -0
- metadata +45 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
class CreatePgSqlTriggersTables < ActiveRecord::Migration[6.
|
|
3
|
+
class CreatePgSqlTriggersTables < ActiveRecord::Migration[6.1]
|
|
4
4
|
def change
|
|
5
5
|
# Registry table - source of truth for all triggers
|
|
6
6
|
create_table :pg_sql_triggers_registry do |t|
|
|
@@ -14,6 +14,7 @@ class CreatePgSqlTriggersTables < ActiveRecord::Migration[6.0]
|
|
|
14
14
|
t.text :definition # Stored DSL or SQL definition
|
|
15
15
|
t.text :function_body # The actual function body
|
|
16
16
|
t.text :condition # Optional WHEN clause condition
|
|
17
|
+
t.string :timing, default: "before", null: false # Trigger timing: before or after
|
|
17
18
|
t.datetime :installed_at
|
|
18
19
|
t.datetime :last_verified_at
|
|
19
20
|
|
|
@@ -25,5 +26,6 @@ class CreatePgSqlTriggersTables < ActiveRecord::Migration[6.0]
|
|
|
25
26
|
add_index :pg_sql_triggers_registry, :enabled
|
|
26
27
|
add_index :pg_sql_triggers_registry, :source
|
|
27
28
|
add_index :pg_sql_triggers_registry, :environment
|
|
29
|
+
add_index :pg_sql_triggers_registry, :timing
|
|
28
30
|
end
|
|
29
31
|
end
|
data/docs/README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# PgSqlTriggers Documentation
|
|
2
|
+
|
|
3
|
+
Welcome to the PgSqlTriggers documentation. This directory contains comprehensive guides and references for all features.
|
|
4
|
+
|
|
5
|
+
## Documentation Index
|
|
6
|
+
|
|
7
|
+
### Getting Started
|
|
8
|
+
- **[Getting Started Guide](getting-started.md)** - Installation, setup, and your first trigger
|
|
9
|
+
|
|
10
|
+
### Core Guides
|
|
11
|
+
- **[Usage Guide](usage-guide.md)** - DSL syntax, migrations, and drift detection
|
|
12
|
+
- **[Web UI Guide](web-ui.md)** - Using the web dashboard
|
|
13
|
+
- **[Kill Switch Guide](kill-switch.md)** - Production safety features
|
|
14
|
+
|
|
15
|
+
### Reference
|
|
16
|
+
- **[Configuration Reference](configuration.md)** - Complete configuration options
|
|
17
|
+
- **[API Reference](api-reference.md)** - Console API and programmatic usage
|
|
18
|
+
|
|
19
|
+
## Quick Links
|
|
20
|
+
|
|
21
|
+
### I want to...
|
|
22
|
+
|
|
23
|
+
#### Install PgSqlTriggers
|
|
24
|
+
Start with [Getting Started](getting-started.md)
|
|
25
|
+
|
|
26
|
+
#### Learn the DSL syntax
|
|
27
|
+
See [Usage Guide - Declaring Triggers](usage-guide.md#declaring-triggers)
|
|
28
|
+
|
|
29
|
+
#### Understand migrations
|
|
30
|
+
See [Usage Guide - Trigger Migrations](usage-guide.md#trigger-migrations)
|
|
31
|
+
|
|
32
|
+
#### Use the web dashboard
|
|
33
|
+
See [Web UI Documentation](web-ui.md)
|
|
34
|
+
|
|
35
|
+
#### Protect production
|
|
36
|
+
See [Kill Switch Documentation](kill-switch.md)
|
|
37
|
+
|
|
38
|
+
#### Configure permissions
|
|
39
|
+
See [Configuration - Permission System](configuration.md#permission-system)
|
|
40
|
+
|
|
41
|
+
#### Use the console API
|
|
42
|
+
See [API Reference](api-reference.md)
|
|
43
|
+
|
|
44
|
+
#### Handle drift detection
|
|
45
|
+
See [Usage Guide - Drift Detection](usage-guide.md#drift-detection)
|
|
46
|
+
|
|
47
|
+
## Screenshots
|
|
48
|
+
|
|
49
|
+
Screenshots referenced in the documentation are stored in the [screenshots](screenshots/) directory.
|
|
50
|
+
|
|
51
|
+
## Contributing to Documentation
|
|
52
|
+
|
|
53
|
+
When updating documentation:
|
|
54
|
+
|
|
55
|
+
1. Keep examples realistic and practical
|
|
56
|
+
2. Include both basic and advanced usage
|
|
57
|
+
3. Add cross-references between related topics
|
|
58
|
+
4. Update this index when adding new pages
|
|
59
|
+
5. Place screenshots in the `screenshots/` directory
|
|
60
|
+
6. Use relative links for internal documentation
|
|
61
|
+
|
|
62
|
+
## External Resources
|
|
63
|
+
|
|
64
|
+
- [GitHub Repository](https://github.com/samaswin87/pg_sql_triggers)
|
|
65
|
+
- [Example Application](https://github.com/samaswin87/pg_triggers_example)
|
|
66
|
+
- [RubyGems](https://rubygems.org/gems/pg_sql_triggers)
|