mirror of
https://github.com/barkeser2002/offline-db.git
synced 2026-09-25 05:20:06 +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.
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
import mysql.connector
|
||
from mysql.connector import Error
|
||
from config import DB_CONFIG
|
||
|
||
def migrate_to_innodb():
|
||
"""
|
||
Tüm MyISAM tablolarını InnoDB'ye dönüştür.
|
||
"""
|
||
try:
|
||
conn = mysql.connector.connect(
|
||
host=DB_CONFIG["host"],
|
||
user=DB_CONFIG["user"],
|
||
password=DB_CONFIG["password"],
|
||
database=DB_CONFIG["database"]
|
||
)
|
||
cursor = conn.cursor()
|
||
|
||
# Tüm tabloları listele
|
||
cursor.execute("SHOW TABLES")
|
||
tables = [table[0] for table in cursor.fetchall()]
|
||
|
||
# Her tabloyu InnoDB'ye dönüştür
|
||
for table in tables:
|
||
print(f"'{table}' tablosu dönüştürülüyor...")
|
||
cursor.execute(f"ALTER TABLE {table} ENGINE=InnoDB")
|
||
print(f"'{table}' tablosu başarıyla InnoDB'ye dönüştürüldü.")
|
||
|
||
print("\nTüm tablolar başarıyla InnoDB'ye dönüştürüldü.")
|
||
|
||
except Error as e:
|
||
print(f"[DB] Hata: {e}")
|
||
finally:
|
||
if conn and conn.is_connected():
|
||
cursor.close()
|
||
conn.close()
|
||
|
||
if __name__ == "__main__":
|
||
migrate_to_innodb()
|