Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f44251d9

Von Moritz Bunkus vor mehr als 14 Jahren hinzugefügt

Schema von contacts immer anpassen

Auch wenn in contacts noch keine EintrÀge existieren, muss das
Datenbankschema angepasst werden.

Unterschiede anzeigen:

sql/Pg-upgrade2/cp_greeting_migration.pl
85 85
  print $main::form->parse_html_template("dbupgrade/cp_greeting_update_form");
86 86
}
87 87

  
88
sub alter_schema_only {
89
  my $sqlcode = <<SQL;
90
    ALTER TABLE contacts ADD COLUMN cp_gender char(1);
91
    ALTER TABLE contacts DROP COLUMN cp_greeting;
92
SQL
93

  
94
  $dbh->do($sqlcode);
95
}
96

  
88 97
sub do_update {
89 98
  # main function
90 99

  
91 100
  # Do not ask the user anything if there are no entries in the
92 101
  # contacts table.
93 102
  my ($data_exists) = $dbh->selectrow_array("SELECT * FROM contacts LIMIT 1");
94
  return 1 if !$data_exists;
103
  if (!$data_exists) {
104
    alter_schema_only();
105
    return 1;
106
  }
95 107

  
96 108
  # first of all check if gender.sql was already run and thus cp_gender exists
97 109
  # if it exists there is no need for this update anymore, so return

Auch abrufbar als: Unified diff