← All changes
|
app/Migrations/AddTaxFieldsToBookingsMigration.php
+5
-4
3.0.2.8
→
3.0.16
View file →
| @@ -1,8 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Yatra\Migrations; |
| 4 | 4 | |
| 5 | +use Yatra\Database\Tables\BookingsTable; | |
| 6 | + | |
| 5 | 7 | /** |
| 6 | 8 | * Add Tax Fields to Bookings Migration |
| 7 | 9 | * |
| 8 | 10 | * Adds tax-related columns to the bookings table for comprehensive tax tracking |
| @@ -25,9 +27,9 @@ | ||
| 25 | 27 | public static function up(): bool |
| 26 | 28 | { |
| 27 | 29 | global $wpdb; |
| 28 | 30 | |
| 29 | - $tableName = $wpdb->prefix . 'yatra_new_bookings'; | |
| 31 | + $tableName = BookingsTable::getTableName(); | |
| 30 | 32 | |
| 31 | 33 | // Check if tax_amount column already exists |
| 32 | 34 | $columnExists = $wpdb->get_var($wpdb->prepare( |
| 33 | 35 | "SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS |
| @@ -62,9 +64,9 @@ | ||
| 62 | 64 | public static function down(): bool |
| 63 | 65 | { |
| 64 | 66 | global $wpdb; |
| 65 | 67 | |
| 66 | - $tableName = $wpdb->prefix . 'yatra_new_bookings'; | |
| 68 | + $tableName = BookingsTable::getTableName(); | |
| 67 | 69 | |
| 68 | 70 | // Remove tax columns |
| 69 | 71 | $sql = "ALTER TABLE `{$tableName}` |
| 70 | 72 | DROP COLUMN `subtotal`, |
| @@ -97,9 +99,9 @@ | ||
| 97 | 99 | public static function updateExistingBookings(): int |
| 98 | 100 | { |
| 99 | 101 | global $wpdb; |
| 100 | 102 | |
| 101 | - $tableName = $wpdb->prefix . 'yatra_new_bookings'; | |
| 103 | + $tableName = BookingsTable::getTableName(); | |
| 102 | 104 | |
| 103 | 105 | // Get bookings without tax data |
| 104 | 106 | $bookings = $wpdb->get_results(" |
| 105 | 107 | SELECT id, total_amount, contact_country |
| @@ -153,9 +155,8 @@ | ||
| 153 | 155 | $updated++; |
| 154 | 156 | } |
| 155 | 157 | } catch (\Exception $e) { |
| 156 | 158 | // Log error but continue with other bookings |
| 157 | - error_log('[Yatra] Tax migration error for booking ' . $booking->id . ': ' . $e->getMessage()); | |
| 158 | 159 | } |
| 159 | 160 | } |
| 160 | 161 | |
| 161 | 162 | return $updated; |