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 #2852 from FireLemons/store_and_display_time_of_la…
…test_deploy Store and display time of latest deploy attempt #4
- Loading branch information
Showing
7 changed files
with
58 additions
and
12 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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class Health < ApplicationRecord | ||
# The "singleton_guard" column is a unique column which must always be set to '0' | ||
# This ensures that only one Health row is created | ||
validates_inclusion_of :singleton_guard, in: [0] | ||
|
||
def self.instance | ||
first_or_create!(singleton_guard: 0) | ||
end | ||
end | ||
|
||
# == Schema Information | ||
# | ||
# Table name: healths | ||
# | ||
# id :bigint not null, primary key | ||
# latest_deploy_time :datetime | ||
# singleton_guard :integer | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
# Indexes | ||
# | ||
# index_healths_on_singleton_guard (singleton_guard) UNIQUE | ||
# |
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,12 @@ | ||
class CreateHealths < ActiveRecord::Migration[6.1] | ||
def change | ||
create_table :healths do |t| | ||
t.timestamp :latest_deploy_time | ||
t.integer :singleton_guard | ||
|
||
t.timestamps | ||
end | ||
|
||
add_index(:healths, :singleton_guard, unique: true) | ||
end | ||
end |
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
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,6 @@ | ||
FactoryBot.define do | ||
factory :health do | ||
latest_deploy_time { Time.now } | ||
singleton_guard { 0 } | ||
end | ||
end |
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,5 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Health, type: :model do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
end |