-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Adrian Herrmann
committed
Sep 25, 2024
1 parent
1dbe9bc
commit 6efcb38
Showing
11 changed files
with
119 additions
and
3 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
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,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class Versioning::Reverters::WellReverter < Versioning::Reverters::BaseReverter | ||
def self.scope | ||
Well.with_deleted | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
module Versioning | ||
module Serializers | ||
class WellSerializer < Versioning::Serializers::BaseSerializer | ||
def self.call(record, name) | ||
new(record: record, name: name).call | ||
end | ||
|
||
def field_definitions | ||
{ | ||
color_code: { | ||
label: 'Color Code', | ||
revert: %i[color_code], | ||
}, | ||
sample_id: { | ||
label: 'Sample ID', | ||
revert: %i[sample_id], | ||
}, | ||
readouts: { | ||
label: 'Readouts', | ||
revert: %i[readouts], | ||
formatter: array_formatter, | ||
}, | ||
}.with_indifferent_access | ||
end | ||
end | ||
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,28 @@ | ||
# frozen_string_literal: true | ||
|
||
class AddLogidzeToWells < ActiveRecord::Migration[6.1] | ||
def change | ||
add_column :wells, :log_data, :jsonb | ||
|
||
reversible do |dir| | ||
dir.up do | ||
create_trigger :logidze_on_wells, on: :wells | ||
end | ||
|
||
dir.down do | ||
execute <<~SQL.squish | ||
DROP TRIGGER IF EXISTS "logidze_on_wells" on "wells"; | ||
SQL | ||
end | ||
end | ||
|
||
reversible do |dir| | ||
dir.up do | ||
execute <<~SQL.squish | ||
UPDATE wells as t | ||
SET log_data = logidze_snapshot(to_jsonb(t), 'updated_at'); | ||
SQL | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CREATE TRIGGER "logidze_on_wells" | ||
BEFORE UPDATE OR INSERT ON "wells" FOR EACH ROW | ||
WHEN (coalesce(current_setting('logidze.disabled', true), '') <> 'on') | ||
-- Parameters: history_size_limit (integer), timestamp_column (text), filtered_columns (text[]), | ||
-- include_columns (boolean), debounce_time_ms (integer) | ||
EXECUTE PROCEDURE logidze_logger(null, 'updated_at'); |