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

Migration for PR #5660 #5664

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* 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 async function up(knex) {
await knex.schema.alterTable("onerep_profiles", (table) => {
table
.specificType("first_names", "character varying(255)[]")
.notNullable()
.defaultTo(knex.raw(`ARRAY[]::character varying(255)[]`));
table
.specificType("last_names", "character varying(255)[]")
.notNullable()
.defaultTo(knex.raw(`ARRAY[]::character varying(255)[]`));
table
.specificType("middle_names", "character varying(255)[]")
.notNullable()
.defaultTo(knex.raw(`ARRAY[]::character varying(255)[]`));
table
.specificType("phone_numbers", "character varying(255)[]")
.notNullable()
.defaultTo(knex.raw(`ARRAY[]::character varying(255)[]`));
table.jsonb("addresses").notNullable().defaultTo("[]");
});
}

/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
export async function down(knex) {
await knex.schema.alterTable("onerep_profiles", (table) => {
table.dropColumns(
"first_names",
"last_names",
"middle_names",
"phone_numbers",
"addresses",
);
});
}
18 changes: 16 additions & 2 deletions src/knex-tables.d.ts
Original file line number Diff line number Diff line change
@@ -347,18 +347,32 @@ declare module "knex/types/tables" {
"id" | "created_at" | "updated_at"
>;

type OnerepProfileAddress = {
city: string;
state: StateAbbr;
};

interface OnerepProfileRow {
id: number;
onerep_profile_id: null | number;
name_suffix: null | string;
first_name: string;
middle_name: null | string;
last_name: string;
city_name: string;
state_code: StateAbbr;
first_names: string[];
middle_names: string[];
last_names: string[];
addresses: OnerepProfileAddress[];
phone_numbers: E164PhoneNumberString[];
date_of_birth: Date;
created_at: Date;
updated_at: Date;
// For backwards compatibility reasons we are keeping `city_name` and
// `state_code` until MNTOR-3567 is implemented and enabled by default.
/** @deprecated Please use `addresses` instead. */
city_name: string;
/** @deprecated Please use `addresses` instead. */
state_code: StateAbbr;
}
type OnerepProfileOptionalColumns = Extract<
keyof OnerepProfileRow,
Loading