mirror of
https://github.com/Evolix/chexpire.git
synced 2024-05-04 17:55:11 +02:00
Create CheckLog model
This commit is contained in:
parent
53fb0d38de
commit
ec4dc321f6
|
@ -28,6 +28,7 @@
|
|||
|
||||
class Check < ApplicationRecord
|
||||
belongs_to :user
|
||||
has_many :logs, class_name: "CheckLog"
|
||||
|
||||
enum kind: [:domain, :ssl]
|
||||
|
||||
|
|
28
app/models/check_log.rb
Normal file
28
app/models/check_log.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: check_logs
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# error :text(65535)
|
||||
# exit_status :integer
|
||||
# parsed_response :text(65535)
|
||||
# raw_response :text(65535)
|
||||
# status :integer
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# check_id :bigint(8)
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_check_logs_on_check_id (check_id)
|
||||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# fk_rails_... (check_id => checks.id)
|
||||
#
|
||||
|
||||
class CheckLog < ApplicationRecord
|
||||
belongs_to :check
|
||||
|
||||
enum status: [:pending, :succeed, :failed]
|
||||
end
|
14
db/migrate/20180530123611_create_check_logs.rb
Normal file
14
db/migrate/20180530123611_create_check_logs.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
class CreateCheckLogs < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
create_table :check_logs do |t|
|
||||
t.references :check, foreign_key: true
|
||||
t.text :raw_response
|
||||
t.integer :exit_status
|
||||
t.text :parsed_response
|
||||
t.text :error
|
||||
t.integer :status
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
15
db/schema.rb
15
db/schema.rb
|
@ -10,7 +10,19 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2018_05_29_092950) do
|
||||
ActiveRecord::Schema.define(version: 2018_05_30_123611) do
|
||||
|
||||
create_table "check_logs", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
||||
t.bigint "check_id"
|
||||
t.text "raw_response"
|
||||
t.integer "exit_status"
|
||||
t.text "parsed_response"
|
||||
t.text "error"
|
||||
t.integer "status"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["check_id"], name: "index_check_logs_on_check_id"
|
||||
end
|
||||
|
||||
create_table "checks", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
||||
t.bigint "user_id"
|
||||
|
@ -53,5 +65,6 @@ ActiveRecord::Schema.define(version: 2018_05_29_092950) do
|
|||
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
||||
end
|
||||
|
||||
add_foreign_key "check_logs", "checks"
|
||||
add_foreign_key "checks", "users"
|
||||
end
|
||||
|
|
24
test/fixtures/check_logs.yml
vendored
Normal file
24
test/fixtures/check_logs.yml
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: check_logs
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# error :text(65535)
|
||||
# exit_status :integer
|
||||
# parsed_response :text(65535)
|
||||
# raw_response :text(65535)
|
||||
# status :integer
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# check_id :bigint(8)
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_check_logs_on_check_id (check_id)
|
||||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# fk_rails_... (check_id => checks.id)
|
||||
#
|
||||
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
30
test/models/check_log_test.rb
Normal file
30
test/models/check_log_test.rb
Normal file
|
@ -0,0 +1,30 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: check_logs
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# error :text(65535)
|
||||
# exit_status :integer
|
||||
# parsed_response :text(65535)
|
||||
# raw_response :text(65535)
|
||||
# status :integer
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# check_id :bigint(8)
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
# index_check_logs_on_check_id (check_id)
|
||||
#
|
||||
# Foreign Keys
|
||||
#
|
||||
# fk_rails_... (check_id => checks.id)
|
||||
#
|
||||
|
||||
require "test_helper"
|
||||
|
||||
class CheckLogTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Loading…
Reference in a new issue