forked from collectiveidea/audited
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make several columns in the audits table NOT NULL
Improve data integrity by adding NOT NULL constraints to columns that should _always_ have a value. This helps catch application and library bugs earlier by catching mishandling of data. Fixes collectiveidea#572
- Loading branch information
Showing
5 changed files
with
48 additions
and
15 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
lib/generators/audited/templates/change_audits_columns_not_null.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,21 @@ | ||
# frozen_string_literal: true | ||
|
||
class <%= migration_class_name %> < <%= migration_parent %> | ||
def self.up | ||
change_column_null :audits, :auditable_id, false | ||
change_column_null :audits, :auditable_type, false | ||
change_column_null :audits, :action, false | ||
change_column_null :audits, :audited_changes, false | ||
change_column_null :audits, :version, false | ||
change_column_null :audits, :created_at, false | ||
end | ||
|
||
def self.down | ||
change_column_null :audits, :auditable_id, true | ||
change_column_null :audits, :auditable_type, true | ||
change_column_null :audits, :action, true | ||
change_column_null :audits, :audited_changes, true | ||
change_column_null :audits, :version, true | ||
change_column_null :audits, :created_at, 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
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