Renaming mailing tables to better names.

This commit is contained in:
Martin Kamerbeek 2010-06-03 12:10:07 +02:00
parent da2ea4d62b
commit a1d8ab6f70
4 changed files with 16 additions and 5 deletions

View file

@ -48,7 +48,7 @@ sub crud_definition {
my $definition = $class->SUPER::crud_definition( $session );
$definition->{ tableName } = 'WGMailing';
$definition->{ tableName } = 'Mailing';
$definition->{ tableKey } = 'mailingId';
$definition->{ sequenceKey } = 'issueId';
@ -143,7 +143,7 @@ sub getStatusLine {
my $db = $self->session->db;
my $sth = $db->read(
'select status, isTest, count( status ) as cnt from WGMailing_queue where mailingId=? group by status,isTest',
'select status, isTest, count( status ) as cnt from Mailing_email where mailingId=? group by status,isTest',
[
$self->getId,
],

View file

@ -58,7 +58,7 @@ sub www_bounceReport {
my $self = shift;
my $session = $self->session;
my $i18n = WebGUI::International->new( $session, 'MailingManager' );
my $sth = $session->db->read( 'select distinct sentTo from WGMailing_queue where sentTo is not null' );
my $sth = $session->db->read( 'select distinct sentTo from Mailing_email where sentTo is not null' );
my $output = '<table><tr><th>'.$i18n->get('email').'</th><th>'.$i18n->get('bounce score').'</th></tr>';
while ( my ($email) = $sth->array ) {

View file

@ -14,7 +14,7 @@ sub crud_definition {
my $definition = $class->SUPER::crud_definition( $session );
$definition->{ tableName } = 'WGMailing_queue';
$definition->{ tableName } = 'Mailing_email';
$definition->{ tableKey } = 'mailId';
$definition->{ sequenceKey } = 'mailingId';

View file

@ -34,7 +34,6 @@ renamespaceTemplates( $session );
finish($session);
#----------------------------------------------------------------------------
sub installMailableAspectTable {
my $session = shift;
@ -152,8 +151,20 @@ sub addRecentColumnToNewsletterCollection {
#----------------------------------------------------------------------------
sub installMailingTables {
my $session = shift;
my $db = $session->db;
print "\tInstalling Mailing table...";
# Remname tables from a previous (bad) name to a new (good) one.
# Must be done before the crudCreateOrUpdate calls to prevent creation of stale tables.
my @tables = $db->buildArray( 'show tables' );
if ( grep { $_ eq 'WGMailing' } @tables ) {
$db->write( 'rename table WGMailing to Mailing' );
}
if ( grep { $_ eq 'WGMailing_queue' } @tables ) {
$db->write( 'rename table WGMailing_queue to Mailing_email' );
}
# Create or update Mailing tables.
use WebGUI::Mailing;
use WebGUI::Mailing::Email;