Skip to content

Commit

Permalink
Merge pull request #5479 from mozilla/MNTOR-3919-1
Browse files Browse the repository at this point in the history
MNTOR-3919: db table changes for churn email column (Part 1)
  • Loading branch information
mansaj authored Jan 13, 2025
2 parents 0fff518 + de783c8 commit 178f115
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ const mockedSubscriber: SubscriberRow = {
monthly_monitor_report: false,
sign_in_count: null,
first_broker_removal_email_sent: false,
churn_prevention_email_sent_at: null,
};

const mockedUser: Session["user"] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ const mockedSubscriber: SubscriberRow = {
monthly_monitor_report: false,
sign_in_count: null,
first_broker_removal_email_sent: false,
churn_prevention_email_sent_at: null,
};

const mockedUser: Session["user"] = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function up (knex) {
return knex.schema.table("subscribers", table => {
table.timestamp("churn_prevention_email_sent_at");
table.index("churn_prevention_email_sent_at");
});
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export function down (knex) {
return knex.schema.table("subscribers", table => {
table.dropIndex("churn_prevention_email_sent_at")
table.dropColumn("churn_prevention_email_sent_at");
});
}
2 changes: 2 additions & 0 deletions src/knex-tables.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ declare module "knex/types/tables" {
sign_in_count: null | number;
email_addresses: SubscriberEmail[];
first_broker_removal_email_sent: boolean;
churn_prevention_email_sent_at: null | Date;
}
type SubscriberOptionalColumns = Extract<
keyof SubscriberRow,
Expand All @@ -174,6 +175,7 @@ declare module "knex/types/tables" {
| "onerep_profile_id"
| "email_addresses"
| "first_broker_removal_email_sent"
| "churn_prevention_email_sent_at"
>;
type SubscriberAutoInsertedColumns = Extract<
keyof SubscriberRow,
Expand Down
7 changes: 7 additions & 0 deletions src/utils/subscriberBreaches.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ const subscriber: SubscriberRow = {
monthly_monitor_report: false,
sign_in_count: null,
first_broker_removal_email_sent: false,
churn_prevention_email_sent_at: null,
};

const allBreaches: HibpLikeDbBreach[] = [
Expand Down Expand Up @@ -550,6 +551,7 @@ describe("getSubBreaches", () => {
onerep_profile_id: null,
sign_in_count: null,
first_broker_removal_email_sent: false,
churn_prevention_email_sent_at: null,
};

(
Expand Down Expand Up @@ -649,6 +651,7 @@ describe("getSubBreaches", () => {
onerep_profile_id: null,
sign_in_count: null,
first_broker_removal_email_sent: false,
churn_prevention_email_sent_at: null,
};

(
Expand Down Expand Up @@ -756,6 +759,7 @@ describe("getSubBreaches", () => {
onerep_profile_id: null,
sign_in_count: null,
first_broker_removal_email_sent: false,
churn_prevention_email_sent_at: null,
};

(
Expand Down Expand Up @@ -873,6 +877,7 @@ describe("getSubBreaches", () => {
onerep_profile_id: null,
sign_in_count: null,
first_broker_removal_email_sent: false,
churn_prevention_email_sent_at: null,
};

(
Expand Down Expand Up @@ -990,6 +995,7 @@ describe("getSubBreaches", () => {
onerep_profile_id: null,
sign_in_count: null,
first_broker_removal_email_sent: false,
churn_prevention_email_sent_at: null,
};

(
Expand Down Expand Up @@ -1103,6 +1109,7 @@ describe("getSubBreaches", () => {
onerep_profile_id: null,
sign_in_count: null,
first_broker_removal_email_sent: false,
churn_prevention_email_sent_at: null,
};

(
Expand Down

0 comments on commit 178f115

Please sign in to comment.