From d74129306d8d5a903af6fe3957046feb36affdd1 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Tue, 8 Jul 2014 15:33:44 +0800 Subject: Bug 990980: create an extension for server-side filtering of bugmail (schema only) --- extensions/BugmailFilter/Config.pm | 15 +++++++ extensions/BugmailFilter/Extension.pm | 82 +++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 extensions/BugmailFilter/Config.pm create mode 100644 extensions/BugmailFilter/Extension.pm (limited to 'extensions/BugmailFilter') diff --git a/extensions/BugmailFilter/Config.pm b/extensions/BugmailFilter/Config.pm new file mode 100644 index 000000000..9932afb40 --- /dev/null +++ b/extensions/BugmailFilter/Config.pm @@ -0,0 +1,15 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. + +package Bugzilla::Extension::BugmailFilter; +use strict; + +use constant NAME => 'BugmailFilter'; +use constant REQUIRED_MODULES => []; +use constant OPTIONAL_MODULES => []; + +__PACKAGE__->NAME; diff --git a/extensions/BugmailFilter/Extension.pm b/extensions/BugmailFilter/Extension.pm new file mode 100644 index 000000000..e4a1be7ff --- /dev/null +++ b/extensions/BugmailFilter/Extension.pm @@ -0,0 +1,82 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. + +package Bugzilla::Extension::BugmailFilter; +use strict; +use warnings; + +use base qw(Bugzilla::Extension); +our $VERSION = '1'; + +# +# schema / install +# + +sub db_schema_abstract_schema { + my ($self, $args) = @_; + $args->{schema}->{bugmail_filters} = { + FIELDS => [ + id => { + TYPE => 'INTSERIAL', + NOTNULL => 1, + PRIMARYKEY => 1, + }, + user_id => { + TYPE => 'INT3', + NOTNULL => 1, + REFERENCES => { + TABLE => 'profiles', + COLUMN => 'userid', + DELETE => 'CASCADE' + }, + }, + field_name => { + # due to fake fields, this can't be field_id + TYPE => 'VARCHAR(64)', + NOTNULL => 0, + }, + product_id => { + TYPE => 'INT2', + NOTNULL => 0, + REFERENCES => { + TABLE => 'products', + COLUMN => 'id', + DELETE => 'CASCADE' + }, + }, + component_id => { + TYPE => 'INT2', + NOTNULL => 0, + REFERENCES => { + TABLE => 'components', + COLUMN => 'id', + DELETE => 'CASCADE' + }, + }, + relationship => { + TYPE => 'INT2', + NOTNULL => 0, + }, + action => { + TYPE => 'INT1', + NOTNULL => 1, + }, + ], + INDEXES => [ + bugmail_filters_unique_idx => { + FIELDS => [ qw( user_id field_name product_id component_id + relationship ) ], + TYPE => 'UNIQUE', + }, + bugmail_filters_user_idx => [ + 'user_id', + ], + ], + }; +} + +__PACKAGE__->NAME; -- cgit v1.2.3-24-g4f1b