Skip to content

Conversation

@shanbady
Copy link
Contributor

@shanbady shanbady commented Mar 15, 2024

What are the relevant tickets?

Closes #3771

Description (What does it do?)

The changes in this PR properly migrate the ProgramCertificate table to its own schema and also includes a database router that prevents writes from happening on tables in the external schema.

How can this be tested?

  1. checkout this branch
  2. run the migrations or do a full docker-compose down+up
  3. in the postgres database see that there is an external schema. in manage.py dbshell you can run the following:
 SELECT nspname
 FROM pg_catalog.pg_namespace;
  1. trying to create a programcertificate in django shell manually should give you an exception:
from profiles.models import ProgramCertificate
ProgramCertificate.objects.get_or_create(user_full_name='john doe',user_email='test@test.com', micromasters_program_id=1, program_title='Supply Chain Management')

Additional Context

Our previous deploy of the programcertificate table ended up create a table in the public schema named "external.programcertificate".

The new migrations in this PR do the following to fix that:

  1. Drop the rogue programcertificate table
  2. recreate the programcertificate table in the external schema

@codecov
Copy link

codecov bot commented Mar 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.75%. Comparing base (f125f24) to head (07d2eb6).
Report is 14 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #617      +/-   ##
==========================================
+ Coverage   74.73%   74.75%   +0.02%     
==========================================
  Files         245      246       +1     
  Lines       11170    11180      +10     
  Branches     1943     1944       +1     
==========================================
+ Hits         8348     8358      +10     
  Misses       2648     2648              
  Partials      174      174              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@shanbady shanbady changed the title Shanbady/separate database router for program certificates2 shanbady/separate database router and schema for program certificates Mar 15, 2024
@shanbady shanbady marked this pull request as ready for review March 15, 2024 19:29
Copy link
Contributor

@ChristopherChudzicki ChristopherChudzicki left a comment

Choose a reason for hiding this comment

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

👍

class Meta:
managed = False
db_table = "external.programcertificate"
db_table = '"external"."programcertificate"'
Copy link
Contributor

Choose a reason for hiding this comment

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

fun.

@shanbady shanbady merged commit 1b9c0ce into main Mar 18, 2024
@shanbady shanbady deleted the shanbady/separate-database-router-for-program-certificates2 branch March 18, 2024 18:35
@odlbot odlbot mentioned this pull request Mar 18, 2024
13 tasks
@odlbot odlbot mentioned this pull request Mar 18, 2024
15 tasks
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.

3 participants