From dc7d2a026d14e0baa7032d7d3aa46d43443969e0 Mon Sep 17 00:00:00 2001 From: Sergey Toy Date: Sun, 16 Apr 2023 20:57:49 +0800 Subject: [PATCH] add writer --- lib/database_consistency.rb | 1 + .../writers/simple/three_state_boolean.rb | 22 +++++++++++++++++++ .../writers/simple_writer.rb | 3 ++- 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 lib/database_consistency/writers/simple/three_state_boolean.rb diff --git a/lib/database_consistency.rb b/lib/database_consistency.rb index a5a6aaf..4a82d8d 100644 --- a/lib/database_consistency.rb +++ b/lib/database_consistency.rb @@ -38,6 +38,7 @@ require 'database_consistency/writers/simple/enum_values_inconsistent_with_ar_enum' require 'database_consistency/writers/simple/enum_values_inconsistent_with_inclusion' require 'database_consistency/writers/simple/redundant_case_insensitive_option' +require 'database_consistency/writers/simple/three_state_boolean' require 'database_consistency/writers/simple_writer' require 'database_consistency/writers/autofix/helpers/migration' diff --git a/lib/database_consistency/writers/simple/three_state_boolean.rb b/lib/database_consistency/writers/simple/three_state_boolean.rb new file mode 100644 index 0000000..553c925 --- /dev/null +++ b/lib/database_consistency/writers/simple/three_state_boolean.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module DatabaseConsistency + module Writers + module Simple + class ThreeStateBoolean < Base # :nodoc: + private + + def template + 'column should be required in the database' + end + + def unique_attributes + { + table_name: report.table_name, + column_name: report.column_name + } + end + end + end + end +end diff --git a/lib/database_consistency/writers/simple_writer.rb b/lib/database_consistency/writers/simple_writer.rb index 091ef30..96dd783 100644 --- a/lib/database_consistency/writers/simple_writer.rb +++ b/lib/database_consistency/writers/simple_writer.rb @@ -28,7 +28,8 @@ class SimpleWriter < BaseWriter missing_foreign_key_cascade: Simple::MissingForeignKeyCascade, enum_values_inconsistent_with_ar_enum: Simple::EnumValuesInconsistentWithArEnum, enum_values_inconsistent_with_inclusion: Simple::EnumValuesInconsistentWithInclusion, - redundant_case_insensitive_option: Simple::RedundantCaseInsensitiveOption + redundant_case_insensitive_option: Simple::RedundantCaseInsensitiveOption, + three_state_boolean: Simple::ThreeStateBoolean }.freeze def write