New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate django_db to sqlite #3203
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR is missing migration for moving existing data from an ArrayField
to JSONField. Have you tested with an existing database created using Mathesar 0.1.3?
I also have a few more concerns which I added as specific comments
config/settings/common_settings.py
Outdated
DATABASES[decouple_config('DJANGO_DATABASE_KEY', default="default")] = decouple_config('DJANGO_DATABASE_URL', cast=db_url) | ||
|
||
try: | ||
DATABASES[decouple_config('DJANGO_DATABASE_KEY', default="default")] = decouple_config('DJANGO_DATABASE_URL', cast=db_url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be better to set the default SQLite dictionary as a default value? The default dictionary can be stored in a variable and used as a default value
DATABASES[decouple_config('DJANGO_DATABASE_KEY', default="default")] = decouple_config('DJANGO_DATABASE_URL', cast=db_url) | |
DEFAULT_DATABASE = { | |
'ENGINE': 'django.db.backends.sqlite3', | |
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), | |
} | |
DATABASES[decouple_config('DJANGO_DATABASE_KEY', default="default")] = decouple_config('DJANGO_DATABASE_URL', cast=db_url, default=DEFAULT_DATABASE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, really clean, but this doesn't work because of cast
. I've added the connection string as the default
now and it works flawlessly.
def to_internal_value(self, data): | ||
column_order = data.get('column_order', None) | ||
if isinstance(column_order, list): | ||
data['column_order'] = list(map(int, column_order)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't setting this validation as a ListField work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😲 Didn't knew setting a child would also typecast, I thought it would just type check. Anyway, fixed now.
mathesar/models/base.py
Outdated
@@ -884,7 +883,7 @@ class PreviewColumnSettings(BaseModel): | |||
class TableSettings(ReflectionManagerMixin, BaseModel): | |||
preview_settings = models.OneToOneField(PreviewColumnSettings, on_delete=models.CASCADE) | |||
table = models.OneToOneField(Table, on_delete=models.CASCADE, related_name="settings") | |||
column_order = ArrayField(models.IntegerField(), null=True, default=None) | |||
column_order = JSONField(null=True, default=list) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the user has not customized the column order, then colum_order will be null.
I made a mistake when we had a sync call I think this should be None
. Look at the issue description
|
Fixes #3055
Technical details
This PR removes the necessity to use postgres for internal django models db, whenever env
DJANGO_DATABASE_URL
is not set the app will now create a fresh sqlite db, however ifDJANGO_DATABASE_URL
is set the app will respect the value of the env variable and create a db for the given db connection.Checklist
Update index.md
).develop
branch of the repositoryvisible errors.
Developer Certificate of Origin
Developer Certificate of Origin