4.3 KiB
4.3 KiB
Column Rename: finish_date → end_date
Overview
Renamed the finish_date column to end_date across the entire billing module for better semantic clarity. The column represents when a server's subscription ends/expires, so "end_date" is more descriptive.
Files Modified
Database Schema
-
module.php - Line 77
- Updated schema definition:
finish_dateDATETIME NULL →end_dateDATETIME NULL
- Updated schema definition:
-
migration_to_invoices.sql
- Line 26: Updated AFTER clause in ADD COLUMN statement
- Lines 49-60: Updated column conversion logic from VARCHAR to DATETIME
- All references to the column name updated
PHP Application Code
-
cron-shop.php (19 occurrences)
- Lines 78-80: Updated query conditions checking end_date IS NOT NULL
- Lines 97, 121, 124: Updated email notification date formatting
- Lines 142, 150-151: Updated suspension query conditions
- Lines 218, 226-227: Updated deletion query conditions
- Lines 283, 288: Updated legacy code comments and queries
- Lines 301, 304: Updated developer notes
- Lines 336, 341: Updated suspension logic
- Line 395: Updated final cleanup query
-
cart.php (14 occurrences)
- Lines 89-106: Updated variable names from $finish_date to $end_date
- Line 111: Updated column existence check
- Lines 117, 119, 121, 127: Updated SQL UPDATE statements
- Line 148-149: Updated audit logging
-
my_account.php (4 occurrences)
- Line 128: Updated SELECT query field
- Line 328: Updated display formatting (3 references in same line)
-
my_servers.php (2 occurrences)
- Line 43: Updated SQL comment
- Line 44: Updated column alias
-
admin_invoices.php (1 occurrence)
- Line 99: Updated display column
-
add_to_cart.php (10 occurrences)
- Lines 134-151: Updated variable names, column checks, INSERT queries, logging
-
create_servers.php (12 occurrences)
- Line 244: Updated condition check
- Lines 295-296: Updated comments
- Lines 301-330: Updated variable names in date calculation logic
- Line 342: Updated SET clause in UPDATE query (2 references)
-
payment_success.php (11 occurrences)
- Lines 35-102: Updated all references in payment processing logic
- Variable renamed: $finish_date_val → $end_date_val
- Updated column existence checks and SQL generation
Documentation
-
INVOICE_SYSTEM.md (6 occurrences)
- Line 27: Updated field description
- Line 67: Updated workflow documentation
- Line 74: Updated renewal process
- Line 84: Updated expiration logic
- Line 113: Updated payment completion notes
- Line 124: Updated My Account display notes
-
MIGRATION_SUMMARY.md (4 occurrences)
- Line 11: Updated changelog entry
- Line 18: Updated bug fix description
- Lines 30, 36: Updated cron process descriptions
- Line 87: Updated SQL schema example
- Line 141: Updated verification notes
Database Impact
For Fresh Installations
- New installations will create the
ogp_billing_orderstable withend_dateDATETIME NULL
For Existing Installations
- Run the updated
migration_to_invoices.sqlscript - The script will handle the column rename automatically using dynamic SQL:
-- Checks if column exists as 'finish_date' and renames to 'end_date' -- Then converts data type from VARCHAR to DATETIME
Testing Checklist
- Module schema updated (module.php)
- Migration script updated (migration_to_invoices.sql)
- All PHP files using the column updated
- All SQL queries updated
- All variable names updated
- All comments and documentation updated
- Verified no remaining
finish_datereferences (except log files)
Backwards Compatibility
⚠️ BREAKING CHANGE: This rename requires running the migration script on existing databases.
Migration Path:
- Backup database
- Run updated
migration_to_invoices.sql - The script will automatically rename
finish_datetoend_date - Verify column exists:
SHOW COLUMNS FROM ogp_billing_orders LIKE 'end_date';
Notes
- Log files may still contain old references to
finish_date- this is expected and harmless - The semantic meaning of the column is unchanged (server expiration date)
- All date calculations remain identical
- No functional changes, only naming improvement for clarity