adilmohak / django-lms

A learning management system using django web framework. Course add and drop, grade and assessment result management, online quiz, report generator, student and lecturers management, dashboard, and so much more...
MIT License
584 stars 251 forks source link

Fix bug in database compatibility #22

Closed WajahatKanju closed 9 months ago

WajahatKanju commented 9 months ago

Database Compatibility Bug Fix

Description

This pull request resolves a bug related to database compatibility in the payments app. The issue occurred when attempting to use databases other than PostgreSQL, resulting in errors during migrations. The problem has been documented in Issue #6.

Changes Made

  1. Migration Update: Modified the migration file to use a JSONField instead of ArrayField with a specified size. This change ensures compatibility with databases such as MariaDB, MySQL, and SQLite.

  2. Initial Data Handling: Added a migration operation (RunPython) to create initial data for the array field specifically for PostgreSQL. This addresses differences in how arrays are handled in PostgreSQL compared to other databases.

Why It Resolved the Issue

The original code specified a size for the ArrayField, which is specific to PostgreSQL and not supported in MySQL. By using a more generic JSONField, we ensure compatibility across different database systems. The added migration operation takes care of specific handling required for PostgreSQL.

Testing

Tested the migration process with the following databases:

All tests passed successfully, confirming that the changes resolve the database compatibility issue.

Related Issues

This pull request addresses the concerns raised in #6

Checklist

adilmohak commented 9 months ago

Amazing. Thank you for resolving the issue.

adilmohak commented 9 months ago

I appreciate the detailed information you provided and also testing it with the four databases.