Skip to content

Commit

Permalink
Make Filter author nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
alhafoudh committed Sep 10, 2024
1 parent 5935dd4 commit cf6ebfa
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/models/everything_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# type :string not null
# created_at :datetime not null
# updated_at :datetime not null
# author_id :bigint not null
# author_id :bigint
# tag_id :bigint
# tenant_id :bigint not null
#
Expand Down
6 changes: 3 additions & 3 deletions app/models/filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
# type :string not null
# created_at :datetime not null
# updated_at :datetime not null
# author_id :bigint not null
# author_id :bigint
# tag_id :bigint
# tenant_id :bigint not null
#
class Filter < ApplicationRecord
include AuditableEvents

belongs_to :author, class_name: 'User'
belongs_to :author, class_name: 'User', optional: true
belongs_to :tenant
has_many :user_filter_visibilities, inverse_of: :filter, dependent: :destroy

validates :tenant_id, :author_id, :name, presence: true
validates :tenant_id, :name, presence: true

before_create :fill_position

Expand Down
2 changes: 1 addition & 1 deletion app/models/fulltext_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# type :string not null
# created_at :datetime not null
# updated_at :datetime not null
# author_id :bigint not null
# author_id :bigint
# tag_id :bigint
# tenant_id :bigint not null
#
Expand Down
2 changes: 1 addition & 1 deletion app/models/tag_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# type :string not null
# created_at :datetime not null
# updated_at :datetime not null
# author_id :bigint not null
# author_id :bigint
# tag_id :bigint
# tenant_id :bigint not null
#
Expand Down
2 changes: 2 additions & 0 deletions app/models/tenant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,7 @@ def create_default_objects
create_signed_externally_tag!(name: "Externe podpísané", visible: false, color: "purple", icon: "shield-check")

make_admins_see_everything!
rescue => ex
binding.pry
end
end
5 changes: 5 additions & 0 deletions db/migrate/20240910112424_change_author_id_null_on_filters.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ChangeAuthorIdNullOnFilters < ActiveRecord::Migration[7.1]
def change
change_column_null :filters, :author_id, true
end
end
4 changes: 2 additions & 2 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cf6ebfa

Please sign in to comment.