Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
#306 Adjusted advanced event listing app to demonstrate DB problem
Browse files Browse the repository at this point in the history
Reproduce the problem with misnamed DB relationships
by running the DB migrations for advancedeventlisting
in a project that uses this app, then try to create
an Advance Event Listing page, at which point the
DB will error with something like:

    relation "advancedeventlisting_advancedeventlistingpage_limit_to_prim561a" does not exist
    LINE 1: ...istingpage_limit_to_prim561a"."eventtype_id" FROM "advancede...
  • Loading branch information
jmurty committed Oct 9, 2017
1 parent 143501c commit e40ddfe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('icekit_plugins_image', '0022_auto_20170622_1024'),
('icekit_events', '0029_fix_malformed_rrules_20170830_1101'),
('icekit_events', '0030_auto_20171002_1551'),
('fluent_pages', '0001_initial'),
('icekit_plugins_location', '0005_auto_20170905_1136'),
('icekit_plugins_location', '0007_auto_20171005_1708'),
('icekit', '0007_auto_20170310_1220'),
]

operations = [
migrations.CreateModel(
name='AdvancedEventListingPage',
fields=[
('urlnode_ptr', models.OneToOneField(auto_created=True, serialize=False, primary_key=True, parent_link=True, to='fluent_pages.UrlNode')),
('urlnode_ptr', models.OneToOneField(primary_key=True, to='fluent_pages.UrlNode', serialize=False, auto_created=True, parent_link=True)),
('brief', models.TextField(help_text=b'A document brief describing the purpose of this content', blank=True)),
('admin_notes', models.TextField(help_text=b"Administrator's notes about this content", blank=True)),
('list_image', models.ImageField(upload_to=b'icekit/listable/list_image/', help_text=b"image to use in listings. Default image is used if this isn't given", blank=True)),
Expand All @@ -31,12 +31,12 @@ class Migration(migrations.Migration):
('limit_to_home_locations', models.BooleanField(default=False)),
('default_start_date', models.DateField(blank=True, help_text=b"Default start date for event occurrences when the user has not selected a value. Leave empty to use today's date", null=True)),
('default_days_to_show', models.IntegerField(blank=True, help_text=b'Default period in days after the start date to show event occurrences when the user has not selected a value. Leave empty to use the value from Events setting `appsettings.DEFAULT_DAYS_TO_SHOW`', null=True)),
('hero_image', models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, null=True, to='icekit_plugins_image.Image', blank=True, related_name='+', help_text=b'The hero image for this content.')),
('layout', models.ForeignKey(null=True, to='icekit.Layout', blank=True, related_name='advancedeventlisting_advancedeventlistingpage_related')),
('limit_to_locations', models.ManyToManyField(db_table=b'advanced_event_listing_page_locations', help_text=b'Leave empty to show all events.', to='icekit_plugins_location.Location', blank=True)),
('limit_to_primary_types', models.ManyToManyField(related_name='_advancedeventlistingpage_limit_to_primary_types_+', db_table=b'advanced_event_listing_page_primary_types', help_text=b'Leave empty to show all events.', to='icekit_events.EventType', blank=True)),
('limit_to_secondary_types', models.ManyToManyField(related_name='_advancedeventlistingpage_limit_to_secondary_types_+', db_table=b'advanced_event_listing_page_secondary_types', help_text=b'Leave empty to show all events.', to='icekit_events.EventType', blank=True)),
('publishing_linked', models.OneToOneField(on_delete=django.db.models.deletion.SET_NULL, null=True, to='advancedeventlisting.AdvancedEventListingPage', related_name='publishing_draft', editable=False)),
('hero_image', models.ForeignKey(related_name='+', to='icekit_plugins_image.Image', null=True, on_delete=django.db.models.deletion.SET_NULL, blank=True, help_text=b'The hero image for this content.')),
('layout', models.ForeignKey(related_name='advancedeventlisting_advancedeventlistingpage_related', to='icekit.Layout', null=True, blank=True)),
('limit_to_locations', models.ManyToManyField(help_text=b'Leave empty to show all events.', to='icekit_plugins_location.Location', blank=True)),
('limit_to_primary_types', models.ManyToManyField(related_name='_advancedeventlistingpage_limit_to_primary_types_+', help_text=b'Leave empty to show all events.', to='icekit_events.EventType', blank=True)),
('limit_to_secondary_types', models.ManyToManyField(related_name='_advancedeventlistingpage_limit_to_secondary_types_+', help_text=b'Leave empty to show all events.', to='icekit_events.EventType', blank=True)),
('publishing_linked', models.OneToOneField(related_name='publishing_draft', to='advancedeventlisting.AdvancedEventListingPage', editable=False, on_delete=django.db.models.deletion.SET_NULL, null=True)),
],
options={
'verbose_name': 'Advanced Event listing',
Expand Down
6 changes: 3 additions & 3 deletions icekit_events/page_types/advancedeventlisting/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ class AbstractAdvancedEventListingPage(AbstractListingPage):
help_text="Leave empty to show all events.",
blank=True,
# Explicit `db_table` required to avoid errors creating FK constraints
db_table="advanced_event_listing_page_primary_types",
#db_table="advanced_event_listing_page_primary_types",
related_name="+",
)
limit_to_secondary_types = models.ManyToManyField(
EventType,
help_text="Leave empty to show all events.",
blank=True,
# Explicit `db_table` required to avoid errors creating FK constraints
db_table="advanced_event_listing_page_secondary_types",
#db_table="advanced_event_listing_page_secondary_types",
related_name="+",
)
limit_to_locations = models.ManyToManyField(
Expand All @@ -34,7 +34,7 @@ class AbstractAdvancedEventListingPage(AbstractListingPage):
help_text="Leave empty to show all events.",
blank=True,
# Explicit `db_table` required to avoid errors creating FK constraints
db_table="advanced_event_listing_page_locations",
#db_table="advanced_event_listing_page_locations",
)
limit_to_home_locations = models.BooleanField(
default=False,
Expand Down

0 comments on commit e40ddfe

Please sign in to comment.