Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 786bfd7a

Von Tamino Steinert vor mehr als 1 Jahr hinzugefügt

  • ID 786bfd7a68e02370d75055852c49791884f17de8
  • Vorgänger e4b272d6
  • Nachfolger 54de916a

EmailSync: EmailJournal erweitert und EmailImport hinzugefügt

Unterschiede anzeigen:

SL/DB/EmailImport.pm
package SL::DB::EmailImport;
use strict;
use SL::DB::MetaSetup::EmailImport;
use SL::DB::Manager::EmailImport;
__PACKAGE__->meta->add_relationship(
email_journal => {
type => 'one to many',
class => 'SL::DB::EmailJournal',
column_map => { id => 'email_import_id' },
},
);
__PACKAGE__->meta->initialize;
1;
SL/DB/Helper/ALL.pm
use SL::DB::Draft;
use SL::DB::Dunning;
use SL::DB::DunningConfig;
use SL::DB::EmailImport;
use SL::DB::EmailJournal;
use SL::DB::EmailJournalAttachment;
use SL::DB::Employee;
SL/DB/Helper/Mappings.pm
drafts => 'draft',
dunning => 'dunning',
dunning_config => 'dunning_config',
email_imports => 'EmailImport',
email_journal => 'EmailJournal',
email_journal_attachments => 'EmailJournalAttachment',
employee => 'employee',
SL/DB/Manager/EmailImport.pm
# This file has been auto-generated only because it didn't exist.
# Feel free to modify it at will; it will not be overwritten automatically.
package SL::DB::Manager::EmailImport;
use strict;
use parent qw(SL::DB::Helper::Manager);
sub object_class { 'SL::DB::EmailImport' }
__PACKAGE__->make_manager_methods;
1;
SL/DB/MetaSetup/EmailImport.pm
# This file has been auto-generated. Do not modify it; it will be overwritten
# by rose_auto_create_model.pl automatically.
package SL::DB::EmailImport;
use strict;
use parent qw(SL::DB::Object);
__PACKAGE__->meta->table('email_imports');
__PACKAGE__->meta->columns(
folder => { type => 'text', not_null => 1 },
host_name => { type => 'text', not_null => 1 },
id => { type => 'serial', not_null => 1 },
itime => { type => 'timestamp', default => 'now()', not_null => 1 },
user_name => { type => 'text', not_null => 1 },
);
__PACKAGE__->meta->primary_key_columns([ 'id' ]);
__PACKAGE__->meta->allow_inline_column_values(1);
1;
;
SL/DB/MetaSetup/EmailJournal.pm
__PACKAGE__->meta->columns(
body => { type => 'text', not_null => 1 },
email_import_id => { type => 'integer' },
extended_status => { type => 'text', not_null => 1 },
folder => { type => 'text' },
from => { type => 'text', not_null => 1 },
headers => { type => 'text', not_null => 1 },
id => { type => 'serial', not_null => 1 },
......
recipients => { type => 'text', not_null => 1 },
sender_id => { type => 'integer' },
sent_on => { type => 'timestamp', default => 'now()', not_null => 1 },
status => { type => 'text', not_null => 1 },
status => { type => 'enum', check_in => [ 'sent', 'send_failed', 'imported' ], db_type => 'email_journal_status', not_null => 1 },
subject => { type => 'text', not_null => 1 },
uid => { type => 'integer' },
);
__PACKAGE__->meta->primary_key_columns([ 'id' ]);
......
__PACKAGE__->meta->allow_inline_column_values(1);
__PACKAGE__->meta->foreign_keys(
email_import => {
class => 'SL::DB::EmailImport',
key_columns => { email_import_id => 'id' },
},
sender => {
class => 'SL::DB::Employee',
key_columns => { sender_id => 'id' },
sql/Pg-upgrade2/email_journal_update.sql
-- @tag: email_import
-- @description: Email Journal für importierte E-Mails erweitern
-- @depends: release_3_8_0
CREATE TABLE email_imports (
id SERIAL NOT NULL PRIMARY KEY,
host_name TEXT NOT NULL,
user_name TEXT NOT NULL,
folder TEXT NOT NULL,
itime TIMESTAMP NOT NULL DEFAULT now()
);
ALTER TABLE email_journal ADD COLUMN email_import_id INTEGER REFERENCES email_imports(id);
ALTER TABLE email_journal ADD COLUMN folder TEXT;
ALTER TABLE email_journal ADD COLUMN uid INTEGER;
CREATE INDEX email_journal_folder_uid_idx ON email_journal (folder, uid);
-- NOTE: change status from text to enum and add 'imported'
CREATE TYPE email_journal_status AS ENUM ('sent', 'send_failed', 'imported');
ALTER TABLE email_journal DROP CONSTRAINT valid_status;
ALTER TABLE email_journal RENAME COLUMN status TO old_status;
ALTER TABLE email_journal ADD COLUMN status email_journal_status;
UPDATE email_journal SET status = 'sent' WHERE old_status = 'ok';
UPDATE email_journal SET status = 'send_failed' WHERE old_status = 'failed';
ALTER TABLE email_journal ALTER COLUMN status SET NOT NULL;
ALTER TABLE email_journal DROP COLUMN old_status;

Auch abrufbar als: Unified diff