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

Add foreign key relationship between SiteModel and NotificationModel #1285

Merged
merged 4 commits into from
Jun 18, 2019

Conversation

AmandaRiu
Copy link
Contributor

Fixes #1284 by adding a foreign key for local_site_id that depends on SiteModel. If the matching site is deleted, the records matching that local_site_id in NotificationModel will deleted automatically.

This PR includes:

  • Update to NotificationModelBuilder to add the foreign key
  • Update to WellSqlConfig to drop NotificationModel on upgrade and recreate the table with the foreign key
  • Updated tests to account for the new SiteModel db dependency as well as a test to verify that the on delete cascade works
  • New DELETE FIRST SITE (DB ONLY) button in the Sites section of the example app. This allows for testing by:
  1. Log in with a Woo account
  2. In the Notifications page, fetch all notifications from the API
  3. In the Sites page, delete the first site from the db
  4. Verify the NotificationModel table using Stethos.

Copy link
Contributor

@anitaa1990 anitaa1990 left a comment

Choose a reason for hiding this comment

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

Looks great! :shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add foreign key relationship between SiteModel and NotificationModel for delete cascade
2 participants