-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from fractaledmind/simplify-installer
Slim down installer and have it use a final schema instead of migrations
- Loading branch information
Showing
4 changed files
with
30 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails/generators" | ||
require "rails/generators/active_record" | ||
|
||
module SolidErrors | ||
# | ||
# Rails generator used for setting up SolidErrors in a Rails application. | ||
# Run it with +bin/rails g solid_errors:install+ in your console. | ||
# | ||
class InstallGenerator < Rails::Generators::Base | ||
include ActiveRecord::Generators::Migration | ||
|
||
source_root File.expand_path("templates", __dir__) | ||
|
||
class_option :database, type: :string, aliases: %i[--db], desc: "The database for your migration. By default, the current environment's primary database is used." | ||
class_option :skip_migrations, type: :boolean, default: nil, desc: "Skip migrations" | ||
|
||
# Generates monolithic migration file that contains all database changes. | ||
def create_migration_file | ||
return if options[:skip_migrations] | ||
|
||
migration_template "create_solid_errors_tables.rb.erb", File.join(db_migrate_path, "create_solid_errors_tables.rb") | ||
end | ||
|
||
private | ||
|
||
def migration_version | ||
"[#{ActiveRecord::VERSION::STRING.to_f}]" | ||
def add_solid_errors_db_schema | ||
template "db/errors_schema.rb" | ||
end | ||
end | ||
end |
24 changes: 0 additions & 24 deletions
24
lib/generators/solid_errors/install/templates/create_solid_errors_tables.rb.erb
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
lib/generators/solid_errors/install/templates/errors_schema.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
ActiveRecord::Schema[7.1].define(version: 1) do | ||
create_table "solid_errors", force: :cascade do |t| | ||
t.text "exception_class", null: false | ||
t.text "message", null: false | ||
t.text "severity", null: false | ||
t.text "source" | ||
t.datetime "resolved_at" | ||
t.string "fingerprint", limit: 64, null: false | ||
t.datetime "created_at", null: false | ||
t.datetime "updated_at", null: false | ||
t.index ["fingerprint"], name: "index_solid_errors_on_fingerprint", unique: true | ||
t.index ["resolved_at"], name: "index_solid_errors_on_resolved_at" | ||
end | ||
|
||
create_table "solid_errors_occurrences", force: :cascade do |t| | ||
t.integer "error_id", null: false | ||
t.text "backtrace" | ||
t.json "context" | ||
t.datetime "created_at", null: false | ||
t.datetime "updated_at", null: false | ||
t.index ["error_id"], name: "index_solid_errors_occurrences_on_error_id" | ||
end | ||
|
||
add_foreign_key "solid_errors_occurrences", "solid_errors", column: "error_id" | ||
end |