Skip to content
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

Jinja2 based routes #1319

Merged
merged 20 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add default value on the database level to prevent release crash
  • Loading branch information
iskhakov committed Mar 7, 2023
commit 5ec760b1fd5d59d3dd9c1f449742bf7e9c38ca4e
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by Django 3.2.17 on 2023-03-06 07:33
# Generated by Django 3.2.17 on 2023-03-07 07:27

from django.db import migrations, models
from django_add_default_value import AddDefaultValue


class Migration(migrations.Migration):
Expand All @@ -13,6 +14,13 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='channelfilter',
name='filtering_term_type',
field=models.IntegerField(choices=[(0, 'regex'), (1, 'jinja2')], default=None, null=True),
field=models.IntegerField(choices=[(0, 'regex'), (1, 'jinja2')], default=0),
),
# Adding same default value on the database level
# for database backwards-compatibility with older versions of code
AddDefaultValue(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is possible with RunSQL to insert default values, but we'll need to do that manually for each database. django_add_default_value does that for us

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't get that idea. Why we need AddDefaultValue, when we have default=0?

Copy link
Contributor Author

@iskhakov iskhakov Mar 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left the better comment in the code
for more details I recommend to read this article

model_name='channelfilter',
name='filtering_term_type',
value=0
)
]
2 changes: 1 addition & 1 deletion engine/apps/alerts/models/channel_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ChannelFilter(OrderedModel):
(FILTERING_TERM_TYPE_REGEX, "regex"),
(FILTERING_TERM_TYPE_JINJA2, "jinja2"),
]
filtering_term_type = models.IntegerField(choices=FILTERING_TERM_TYPE_CHOICES, null=True, default=None)
filtering_term_type = models.IntegerField(choices=FILTERING_TERM_TYPE_CHOICES, default=FILTERING_TERM_TYPE_REGEX)

is_default = models.BooleanField(default=False)

Expand Down
1 change: 1 addition & 0 deletions engine/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ emoji==1.7.0
regex==2021.11.2
psutil==5.9.4
django-migration-linter==4.1.0
django-add-default-value==0.10.0
opentelemetry-instrumentation-celery==0.36b0
opentelemetry-instrumentation-pymysql==0.36b0
opentelemetry-instrumentation-wsgi==0.36b0
Expand Down