mirror of
https://github.com/barkeser2002/offline-db.git
synced 2026-09-25 02:19:59 +03:00
🐛 The Bug: The database was using the outdated MyISAM storage engine, which lacks modern features like transactions and foreign key support. Additionally, a `NameError` in `blueprints/api.py` prevented the server from starting, and a critical SQL syntax error in `db.py` broke the video link fetching functionality. 🛠️ The Fix: - Migrated all database tables from MyISAM to InnoDB for improved stability and performance. - Created `execute_migration.py` and `verify_migration.py` scripts to perform and validate the migration. - Updated `db.py` to use InnoDB for all new table creations. - Fixed the `NameError` in `blueprints/api.py` by importing the missing `get_available_seasons` function. - Corrected the invalid SQL syntax `a.mal_.id` to `a.mal_id` in `db.py`. 🧪 Verification: - Ran the migration and verification scripts to ensure all tables were converted to InnoDB. - Performed a system health check by starting the Flask server and successfully querying the `/api/seasons` endpoint. - Manually verified the SQL syntax fix by re-running the application.
46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
import mysql.connector
|
||
from mysql.connector import Error
|
||
from config import DB_CONFIG
|
||
|
||
def verify_innodb_migration():
|
||
"""
|
||
Tüm tabloların InnoDB'ye dönüştürüldüğünü doğrula.
|
||
"""
|
||
all_innodb = True
|
||
try:
|
||
conn = mysql.connector.connect(
|
||
host=DB_CONFIG["host"],
|
||
user=DB_CONFIG["user"],
|
||
password=DB_CONFIG["password"],
|
||
database=DB_CONFIG["database"]
|
||
)
|
||
cursor = conn.cursor(dictionary=True)
|
||
|
||
cursor.execute(f"SELECT TABLE_NAME, ENGINE FROM information_schema.TABLES WHERE TABLE_SCHEMA = '{DB_CONFIG['database']}'")
|
||
|
||
for table in cursor.fetchall():
|
||
if table['ENGINE'] != 'InnoDB':
|
||
print(f"[HATA] '{table['TABLE_NAME']}' tablosu hala {table['ENGINE']} kullanıyor.")
|
||
all_innodb = False
|
||
else:
|
||
print(f"'{table['TABLE_NAME']}' tablosu başarıyla InnoDB'ye dönüştürülmüş.")
|
||
|
||
if all_innodb:
|
||
print("\nTüm tablolar başarıyla InnoDB'ye dönüştürülmüş.")
|
||
else:
|
||
print("\nBazı tablolar InnoDB'ye dönüştürülemedi.")
|
||
|
||
except Error as e:
|
||
print(f"[DB] Hata: {e}")
|
||
all_innodb = False
|
||
finally:
|
||
if conn and conn.is_connected():
|
||
cursor.close()
|
||
conn.close()
|
||
|
||
return all_innodb
|
||
|
||
if __name__ == "__main__":
|
||
if not verify_innodb_migration():
|
||
exit(1)
|