Skip to content

Commit a618cca

Browse files
authored
Merge pull request #6161 from mozilla/mntor-5015
chore(plus): remove churn and coupon tables and types
2 parents 0417e80 + d557984 commit a618cca

File tree

2 files changed

+42
-33
lines changed

2 files changed

+42
-33
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
/**
6+
* @param { import("knex").Knex } knex
7+
* @returns { Promise<void> }
8+
*/
9+
export async function up(knex) {
10+
await knex.schema.dropTableIfExists("subscriber_churns");
11+
await knex.schema.dropTableIfExists("subscriber_coupons");
12+
}
13+
14+
/**
15+
* @param { import("knex").Knex } knex
16+
* @returns { Promise<void> }
17+
*/
18+
export async function down(knex) {
19+
await knex.schema.createTable("subscriber_churns", function (table) {
20+
table.increments("id").primary();
21+
table.string("userid").unique();
22+
table.string("customer").unique();
23+
table.string("plan_id");
24+
table.string("product_id");
25+
table.string("intervl");
26+
table.string("nickname");
27+
table.timestamp("created");
28+
table.timestamp("current_period_end");
29+
});
30+
await knex.schema.createTable("subscriber_coupons", (table) => {
31+
table.increments("id").primary();
32+
table
33+
.integer("subscriber_id")
34+
.references("subscribers.id")
35+
.notNullable()
36+
.onDelete("CASCADE")
37+
.onUpdate("CASCADE");
38+
table.string("coupon_code").notNullable();
39+
table.timestamp("created_at").defaultTo(knex.fn.now());
40+
table.unique(["subscriber_id", "coupon_code"]);
41+
});
42+
}

src/knex-tables.d.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,6 @@ declare module "knex/types/tables" {
2626
updated_at: Date;
2727
}
2828

29-
interface SubscriberChurnRow {
30-
userid: string;
31-
customer: string;
32-
nickname: string;
33-
intervl: string;
34-
plan_id: string;
35-
product_id: string;
36-
current_period_end: Date;
37-
}
38-
3929
interface OnerepScanResultDataBrokerRow extends OnerepScanResultRow {
4030
scan_result_status: RemovalStatus;
4131
broker_status: DataBrokerRemovalStatus;
@@ -213,17 +203,6 @@ declare module "knex/types/tables" {
213203
"id" | "created_at" | "updated_at"
214204
>;
215205

216-
interface SubscriberCouponRow {
217-
id: number;
218-
subscriber_id: number;
219-
coupon_code: string;
220-
created_at: Date;
221-
}
222-
type SubscriberCouponAutoInsertedColumns = Extract<
223-
keyof SubscriberCouponRow,
224-
"id" | "subscriber_id" | "created_at"
225-
>;
226-
227206
interface SubscriberEmailPreferencesRow {
228207
id: number;
229208
subscriber_id: number;
@@ -530,18 +509,6 @@ declare module "knex/types/tables" {
530509
>
531510
>;
532511

533-
subscriber_coupons: Knex.CompositeTableType<
534-
SubscriberCouponRow,
535-
// On inserts, auto-generated columns cannot be set, and nullable columns are optional:
536-
WritableDateColumns<
537-
Omit<SubscriberCouponRow, SubscriberAutoInsertedColumns>
538-
>,
539-
// On updates, don't allow updating the ID; all other fields are optional:
540-
WritableDateColumns<Partial<Omit<SubscriberCouponRow, "id">>>
541-
>;
542-
543-
subscriber_churns: SubscriberChurnRow;
544-
545512
subscriber_email_preferences: Knex.CompositeTableType<
546513
SubscriberEmailPreferencesRow,
547514
// On inserts, auto-generated columns cannot be set, and nullable columns are optional:

0 commit comments

Comments
 (0)