solid_errors 0.5.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef3e4cca2bd412b918d7b7c36b3e754d79fefbc06e754a54fd58d5b04ef02a79
4
- data.tar.gz: 1ca69a12aa28386778c66d7cd9114c06d20fbce1f846bf78391cfcad6796ff63
3
+ metadata.gz: acc9e46b7ee94e391df6d5fa4b11fd0550dcef9eca0f1b2089ec8ea81d6dc47e
4
+ data.tar.gz: 37fda129cbac297cb10da823a70188515f29f57f02160b2acf01fd010345698a
5
5
  SHA512:
6
- metadata.gz: 1d5313d9fd88ce1d75bbd1faf09bd47bca8caaafd61ea7930f982e02b117957b11b077406c5c8109531d7d718a37ee344b136f9fbf483fe371271951ee137b55
7
- data.tar.gz: cd5a876a317307109b4660e39b11be2e80b6fa2b7a5a33db00c3edac84bcf27d0a3dc777a2a3f49837411e4a3168483f2c57656bc18e6d24903d5106400a697c
6
+ metadata.gz: 1f2cd0c74b2a38ac93abb353cc8083cb623b942cd117df06efaf246afc0e42e2cd40732692fb6e7510c2962fab5a3826d88c674c21d1c2582de8264a4ccbca82
7
+ data.tar.gz: 1ecc1ebc03b277fa8840cdc3550ad0e64f566761a3ecdc5ad45a2daa39fde4b8922c528eec6fa3097fd15f098bfcbe7b372bc26197855e5507990d04e1729ce3
data/README.md CHANGED
@@ -49,7 +49,40 @@ After installing the gem, run the installer:
49
49
  $ rails generate solid_errors:install
50
50
  ```
51
51
 
52
- This will copy the required migration over to your app.
52
+ This will create the `db/errors_schema.rb` file.
53
+
54
+ You will then have to add the configuration for the errors database in `config/database.yml`. If you're using sqlite, it'll look something like this:
55
+
56
+ ```yaml
57
+ production:
58
+ primary:
59
+ <<: *default
60
+ database: storage/production.sqlite3
61
+ errors:
62
+ <<: *default
63
+ database: storage/production_errors.sqlite3
64
+ migrations_paths: db/errors_migrate
65
+ ```
66
+
67
+ ...or if you're using MySQL/PostgreSQL/Trilogy:
68
+
69
+ ```yaml
70
+ production:
71
+ primary: &primary_production
72
+ <<: *default
73
+ database: app_production
74
+ username: app
75
+ password: <%= ENV["APP_DATABASE_PASSWORD"] %>
76
+ errors:
77
+ <<: *primary_production
78
+ database: app_production_errors
79
+ migrations_paths: db/errors_migrate
80
+ ```
81
+
82
+ > [!NOTE]
83
+ > Calling `bin/rails solid_errors:install` will automatically add `config.solid_errors.connects_to = { database: { writing: :errors } }` to `config/environments/production.rb`, so no additional configuration is needed there (although you must make sure that you use the `errors` name in `database.yml` for this to match!). But if you want to use Solid Errors in a different environment (like staging or even development), you'll have to manually add that `config.solid_errors.connects_to` line to the respective environment file. And, as always, make sure that the name you're using for the database in `config/database.yml` matches the name you use in `config.solid_errors.connects_to`.
84
+
85
+ Then run `db:prepare` in production to ensure the database is created and the schema is loaded.
53
86
 
54
87
  Then mount the engine in your `config/routes.rb` file:
55
88
  ```ruby
data/config/routes.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  SolidErrors::Engine.routes.draw do
2
- get "/" => "errors#index", :as => :root
2
+ get "/", to: "errors#index", as: :root
3
3
 
4
4
  resources :errors, only: [:index, :show, :update, :destroy], path: ""
5
5
  end
@@ -5,4 +5,4 @@ Example:
5
5
  bin/rails generate solid_errors:install
6
6
 
7
7
  This will perform the following:
8
- Installs solid_errors migrations
8
+ Adds solid_errors db schema
@@ -1,32 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rails/generators"
4
- require "rails/generators/active_record"
5
-
6
3
  module SolidErrors
7
4
  #
8
5
  # Rails generator used for setting up SolidErrors in a Rails application.
9
6
  # Run it with +bin/rails g solid_errors:install+ in your console.
10
7
  #
11
8
  class InstallGenerator < Rails::Generators::Base
12
- include ActiveRecord::Generators::Migration
13
-
14
9
  source_root File.expand_path("templates", __dir__)
15
10
 
16
- class_option :database, type: :string, aliases: %i[--db], desc: "The database for your migration. By default, the current environment's primary database is used."
17
- class_option :skip_migrations, type: :boolean, default: nil, desc: "Skip migrations"
18
-
19
- # Generates monolithic migration file that contains all database changes.
20
- def create_migration_file
21
- return if options[:skip_migrations]
22
-
23
- migration_template "create_solid_errors_tables.rb.erb", File.join(db_migrate_path, "create_solid_errors_tables.rb")
11
+ def add_solid_errors_db_schema
12
+ template "db/errors_schema.rb"
24
13
  end
25
14
 
26
- private
27
-
28
- def migration_version
29
- "[#{ActiveRecord::VERSION::STRING.to_f}]"
15
+ def configure_solid_errors
16
+ insert_into_file Pathname(destination_root).join("config/environments/production.rb"), after: /^([ \t]*).*?(?=\nend)$/ do
17
+ [
18
+ "",
19
+ '\1# Configure Solid Errors',
20
+ '\1config.solid_errors.connects_to = { database: { writing: :errors } }',
21
+ '\1config.solid_errors.send_emails = true',
22
+ '\1config.solid_errors.email_from = ""',
23
+ '\1config.solid_errors.email_to = ""',
24
+ '\1config.solid_errors.username = Rails.application.credentials.dig(:solid_errors, :username)',
25
+ '\1config.solid_errors.password = Rails.application.credentials.dig(:solid_errors, :password)'
26
+ ].join("\n")
27
+ end
30
28
  end
31
29
  end
32
30
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ ActiveRecord::Schema[7.1].define(version: 1) do
4
+ create_table "solid_errors", force: :cascade do |t|
5
+ t.text "exception_class", null: false
6
+ t.text "message", null: false
7
+ t.text "severity", null: false
8
+ t.text "source"
9
+ t.datetime "resolved_at"
10
+ t.string "fingerprint", limit: 64, null: false
11
+ t.datetime "created_at", null: false
12
+ t.datetime "updated_at", null: false
13
+ t.index ["fingerprint"], name: "index_solid_errors_on_fingerprint", unique: true
14
+ t.index ["resolved_at"], name: "index_solid_errors_on_resolved_at"
15
+ end
16
+
17
+ create_table "solid_errors_occurrences", force: :cascade do |t|
18
+ t.integer "error_id", null: false
19
+ t.text "backtrace"
20
+ t.json "context"
21
+ t.datetime "created_at", null: false
22
+ t.datetime "updated_at", null: false
23
+ t.index ["error_id"], name: "index_solid_errors_occurrences_on_error_id"
24
+ end
25
+
26
+ add_foreign_key "solid_errors_occurrences", "solid_errors", column: "error_id"
27
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidErrors
4
- VERSION = "0.5.0"
4
+ VERSION = "0.6.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solid_errors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Margheim
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-22 00:00:00.000000000 Z
11
+ date: 2024-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
@@ -142,7 +142,7 @@ files:
142
142
  - config/routes.rb
143
143
  - lib/generators/solid_errors/install/USAGE
144
144
  - lib/generators/solid_errors/install/install_generator.rb
145
- - lib/generators/solid_errors/install/templates/create_solid_errors_tables.rb.erb
145
+ - lib/generators/solid_errors/install/templates/db/errors_schema.rb
146
146
  - lib/solid_errors.rb
147
147
  - lib/solid_errors/engine.rb
148
148
  - lib/solid_errors/sanitizer.rb
@@ -169,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
169
  - !ruby/object:Gem::Version
170
170
  version: '0'
171
171
  requirements: []
172
- rubygems_version: 3.5.17
172
+ rubygems_version: 3.5.11
173
173
  signing_key:
174
174
  specification_version: 4
175
175
  summary: Database-backed Rails error subscriber
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class CreateSolidErrorsTables < ActiveRecord::Migration<%= migration_version %>
4
- def change
5
- create_table :solid_errors do |t|
6
- t.text :exception_class, null: false
7
- t.text :message, null: false
8
- t.text :severity, null: false
9
- t.text :source
10
- t.datetime :resolved_at, index: true
11
- t.string :fingerprint, null: false, limit: 64, index: { unique: true }
12
-
13
- t.timestamps
14
- end
15
-
16
- create_table :solid_errors_occurrences do |t|
17
- t.belongs_to :error, null: false, foreign_key: { to_table: :solid_errors }
18
- t.text :backtrace
19
- t.json :context
20
-
21
- t.timestamps
22
- end
23
- end
24
- end