Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 5499cd21

Von Tamino Steinert vor mehr als 1 Jahr hinzugefügt

  • ID 5499cd214613da414499856391627d53cc61ee2a
  • Vorgänger 112db55e
  • Nachfolger 2b4a39fa

EmailSync: EmailJournal erweitert und EmailImport hinzugefügt

Unterschiede anzeigen:

SL/DB/EmailImport.pm
1
package SL::DB::EmailImport;
2

  
3
use strict;
4

  
5
use SL::DB::MetaSetup::EmailImport;
6
use SL::DB::Manager::EmailImport;
7

  
8
__PACKAGE__->meta->add_relationship(
9
  email_journal => {
10
    type      => 'one to many',
11
    class     => 'SL::DB::EmailJournal',
12
    column_map => { id => 'email_import_id' },
13
  },
14
);
15

  
16
__PACKAGE__->meta->initialize;
17

  
18
1;
SL/DB/Helper/ALL.pm
56 56
use SL::DB::Draft;
57 57
use SL::DB::Dunning;
58 58
use SL::DB::DunningConfig;
59
use SL::DB::EmailImport;
59 60
use SL::DB::EmailJournal;
60 61
use SL::DB::EmailJournalAttachment;
61 62
use SL::DB::Employee;
SL/DB/Helper/Mappings.pm
138 138
  drafts                         => 'draft',
139 139
  dunning                        => 'dunning',
140 140
  dunning_config                 => 'dunning_config',
141
  email_imports                  => 'EmailImport',
141 142
  email_journal                  => 'EmailJournal',
142 143
  email_journal_attachments      => 'EmailJournalAttachment',
143 144
  employee                       => 'employee',
SL/DB/Manager/EmailImport.pm
1
# This file has been auto-generated only because it didn't exist.
2
# Feel free to modify it at will; it will not be overwritten automatically.
3

  
4
package SL::DB::Manager::EmailImport;
5

  
6
use strict;
7

  
8
use parent qw(SL::DB::Helper::Manager);
9

  
10
sub object_class { 'SL::DB::EmailImport' }
11

  
12
__PACKAGE__->make_manager_methods;
13

  
14
1;
SL/DB/MetaSetup/EmailImport.pm
1
# This file has been auto-generated. Do not modify it; it will be overwritten
2
# by rose_auto_create_model.pl automatically.
3
package SL::DB::EmailImport;
4

  
5
use strict;
6

  
7
use parent qw(SL::DB::Object);
8

  
9
__PACKAGE__->meta->table('email_imports');
10

  
11
__PACKAGE__->meta->columns(
12
  folder    => { type => 'text', not_null => 1 },
13
  host_name => { type => 'text', not_null => 1 },
14
  id        => { type => 'serial', not_null => 1 },
15
  itime     => { type => 'timestamp', default => 'now()', not_null => 1 },
16
  user_name => { type => 'text', not_null => 1 },
17
);
18

  
19
__PACKAGE__->meta->primary_key_columns([ 'id' ]);
20

  
21
__PACKAGE__->meta->allow_inline_column_values(1);
22

  
23
1;
24
;
SL/DB/MetaSetup/EmailJournal.pm
10 10

  
11 11
__PACKAGE__->meta->columns(
12 12
  body            => { type => 'text', not_null => 1 },
13
  email_import_id => { type => 'integer' },
13 14
  extended_status => { type => 'text', not_null => 1 },
15
  folder          => { type => 'text' },
14 16
  from            => { type => 'text', not_null => 1 },
15 17
  headers         => { type => 'text', not_null => 1 },
16 18
  id              => { type => 'serial', not_null => 1 },
......
19 21
  recipients      => { type => 'text', not_null => 1 },
20 22
  sender_id       => { type => 'integer' },
21 23
  sent_on         => { type => 'timestamp', default => 'now()', not_null => 1 },
22
  status          => { type => 'text', not_null => 1 },
24
  status          => { type => 'enum', check_in => [ 'sent', 'send_failed', 'imported' ], db_type => 'email_journal_status', not_null => 1 },
23 25
  subject         => { type => 'text', not_null => 1 },
26
  uid             => { type => 'integer' },
24 27
);
25 28

  
26 29
__PACKAGE__->meta->primary_key_columns([ 'id' ]);
......
28 31
__PACKAGE__->meta->allow_inline_column_values(1);
29 32

  
30 33
__PACKAGE__->meta->foreign_keys(
34
  email_import => {
35
    class       => 'SL::DB::EmailImport',
36
    key_columns => { email_import_id => 'id' },
37
  },
38

  
31 39
  sender => {
32 40
    class       => 'SL::DB::Employee',
33 41
    key_columns => { sender_id => 'id' },
sql/Pg-upgrade2/email_journal_update.sql
1
-- @tag: email_import
2
-- @description: Email Journal für importierte E-Mails erweitern
3
-- @depends: release_3_8_0
4

  
5
CREATE TABLE email_imports (
6
  id              SERIAL    NOT NULL PRIMARY KEY,
7
  host_name       TEXT      NOT NULL,
8
  user_name       TEXT      NOT NULL,
9
  folder          TEXT      NOT NULL,
10
  itime           TIMESTAMP NOT NULL DEFAULT now()
11
);
12

  
13
ALTER TABLE email_journal ADD COLUMN email_import_id INTEGER REFERENCES email_imports(id);
14
ALTER TABLE email_journal ADD COLUMN folder          TEXT;
15
ALTER TABLE email_journal ADD COLUMN uid             INTEGER;
16
CREATE INDEX email_journal_folder_uid_idx ON email_journal (folder, uid);
17
-- NOTE: change status from text to enum and add 'imported'
18
CREATE TYPE email_journal_status AS ENUM ('sent', 'send_failed', 'imported');
19
ALTER TABLE email_journal DROP CONSTRAINT valid_status;
20
ALTER TABLE email_journal RENAME COLUMN status TO old_status;
21
ALTER TABLE email_journal ADD COLUMN status email_journal_status;
22
UPDATE email_journal SET status = 'sent'        WHERE old_status = 'ok';
23
UPDATE email_journal SET status = 'send_failed' WHERE old_status = 'failed';
24
ALTER TABLE email_journal ALTER COLUMN status SET NOT NULL;
25
ALTER TABLE email_journal DROP COLUMN old_status;
26

  
27

  

Auch abrufbar als: Unified diff