Add some safeguarding in case columns do (not) exist

Signed-off-by: phl0 <github@florian-wolters.de>
pull/1826/head
phl0 2022-10-05 21:21:15 +02:00
rodzic 3521c6b003
commit 8de14376ba
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 48EA1E640798CA9A
1 zmienionych plików z 11 dodań i 3 usunięć

Wyświetl plik

@ -29,6 +29,8 @@ class Migration_add_pota_columns extends CI_Migration {
$this->db->where('COL_SIG', 'POTA');
$this->db->update('TABLE_HRD_CONTACTS_V01');
}
if (!$this->db->field_exists('station_pota', 'station_profile')) {
// Add MY_POTA_REF to station profile
$fields = array(
'station_pota varchar(50) DEFAULT NULL',
@ -39,8 +41,14 @@ class Migration_add_pota_columns extends CI_Migration {
public function down()
{
$this->dbforge->drop_column('TABLE_HRD_CONTACTS_V01', 'COL_POTA_REF');
$this->dbforge->drop_column('TABLE_HRD_CONTACTS_V01', 'COL_MY_POTA_REF');
$this->dbforge->drop_column('station_profile', 'station_potpota');
if ($this->db->field_exists('COL_POTA_REF', 'TABLE_HRD_CONTACTS_V01')) {
$this->dbforge->drop_column('TABLE_HRD_CONTACTS_V01', 'COL_POTA_REF');
}
if ($this->db->field_exists('COL_MY_POTA_REF', 'TABLE_HRD_CONTACTS_V01')) {
$this->dbforge->drop_column('TABLE_HRD_CONTACTS_V01', 'COL_MY_POTA_REF');
}
if ($this->db->field_exists('station_pota', 'station_profile')) {
$this->dbforge->drop_column('station_profile', 'station_pota');
}
}
}