Skip to content
This repository was archived by the owner on Sep 20, 2025. It is now read-only.

Commit 0ca73bd

Browse files
committed
Add userAddress.telephone to migrations and seeders
1 parent 3d604ed commit 0ca73bd

File tree

5 files changed

+70
-6
lines changed

5 files changed

+70
-6
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
'use strict';
2+
3+
/** @type {import('sequelize-cli').Migration} */
4+
module.exports = {
5+
async up (queryInterface, Sequelize) {
6+
const transaction = await queryInterface.sequelize.transaction();
7+
try {
8+
await queryInterface.addColumn(
9+
"userAddresses",
10+
"telephoneAreaCode",
11+
{
12+
type: Sequelize.STRING(6),
13+
defaultValue: null,
14+
after: "state",
15+
},
16+
{ transaction },
17+
);
18+
await queryInterface.addColumn(
19+
"userAddresses",
20+
"telephone",
21+
{
22+
type: Sequelize.STRING(30),
23+
after: "telephoneAreaCode",
24+
},
25+
{ transaction },
26+
);
27+
transaction.commit();
28+
} catch (err) {
29+
transaction.rollback();
30+
throw err;
31+
}
32+
},
33+
34+
async down (queryInterface, Sequelize) {
35+
const transaction = await queryInterface.sequelize.transaction();
36+
try {
37+
await queryInterface.removeColumn(
38+
"userAddresses",
39+
"telephoneAreaCode",
40+
{ transaction },
41+
);
42+
await transaction.commit();
43+
} catch (err) {
44+
await transaction.rollback();
45+
throw err;
46+
}
47+
}
48+
};

src/models/v1/userAddress.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,13 @@ module.exports = (sequelize, DataTypes) => {
288288
state: {
289289
type: DataTypes.STRING
290290
},
291+
telephoneAreaCode: {
292+
type: DataTypes.STRING(6),
293+
defaultValue: null,
294+
},
295+
telephone: {
296+
type: DataTypes.STRING(30),
297+
},
291298
createdAt: {
292299
type: DataTypes.DATE,
293300
defaultValue: DataTypes.NOW,

src/seeders/v1/20250627161105-demo-guest-user.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,18 @@ module.exports = {
3131
);
3232
const usersId = userInsertResult[0];
3333
await queryInterface.sequelize.query(
34-
`INSERT INTO userAddresses(usersId, addressLine1, addressLine2, zipCode, city, state, createdAt, updatedAt)
35-
VALUES (:usersId, :addressLine1, :addressLine2, :zipCode, :city, :state, :createdAt, :updatedAt)`,
34+
`INSERT INTO userAddresses(usersId, addressLine1, addressLine2, zipCode, city, state, telephone, createdAt, updatedAt)
35+
VALUES (:usersId, :addressLine1, :addressLine2, :zipCode, :city, :state, :telephone, :createdAt, :updatedAt)`,
3636
{
3737
replacements: {
3838
addressLine1: faker.location.streetAddress(),
3939
addressLine2: faker.location.secondaryAddress(),
4040
zipCode: faker.location.zipCode(),
4141
city: faker.location.city(),
4242
state: faker.location.state(),
43+
telephone: faker.phone.number({
44+
international: true,
45+
}),
4346
createdAt: moment().utc().format(mysqlTimeFormat),
4447
updatedAt: moment().utc().format(mysqlTimeFormat),
4548
usersId,

src/seeders/v1/20250627161357-demo-admin-user.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,18 @@ module.exports = {
3131
);
3232
const usersId = userInsertResult[0];
3333
await queryInterface.sequelize.query(
34-
`INSERT INTO userAddresses(usersId, addressLine1, addressLine2, zipCode, city, state, createdAt, updatedAt)
35-
VALUES (:usersId, :addressLine1, :addressLine2, :zipCode, :city, :state, :createdAt, :updatedAt)`,
34+
`INSERT INTO userAddresses(usersId, addressLine1, addressLine2, zipCode, city, state, telephone, createdAt, updatedAt)
35+
VALUES (:usersId, :addressLine1, :addressLine2, :zipCode, :city, :state, :telephone, :createdAt, :updatedAt)`,
3636
{
3737
replacements: {
3838
addressLine1: faker.location.streetAddress(),
3939
addressLine2: faker.location.secondaryAddress(),
4040
zipCode: faker.location.zipCode(),
4141
city: faker.location.city(),
4242
state: faker.location.state(),
43+
telephone: faker.phone.number({
44+
international: true,
45+
}),
4346
createdAt: moment().utc().format(mysqlTimeFormat),
4447
updatedAt: moment().utc().format(mysqlTimeFormat),
4548
usersId,

src/seeders/v1/20250705172336-demo-guest-users.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,18 @@ module.exports = {
3232
);
3333
const usersId = userInsertResult[0];
3434
await queryInterface.sequelize.query(
35-
`INSERT INTO userAddresses(usersId, addressLine1, addressLine2, zipCode, city, state, createdAt, updatedAt)
36-
VALUES (:usersId, :addressLine1, :addressLine2, :zipCode, :city, :state, :createdAt, :updatedAt)`,
35+
`INSERT INTO userAddresses(usersId, addressLine1, addressLine2, zipCode, city, state, telephone, createdAt, updatedAt)
36+
VALUES (:usersId, :addressLine1, :addressLine2, :zipCode, :city, :state, :telephone, :createdAt, :updatedAt)`,
3737
{
3838
replacements: {
3939
addressLine1: faker.location.streetAddress(),
4040
addressLine2: faker.location.secondaryAddress(),
4141
zipCode: faker.location.zipCode(),
4242
city: faker.location.city(),
4343
state: faker.location.state(),
44+
telephone: faker.phone.number({
45+
international: true,
46+
}),
4447
createdAt: moment().utc().format(mysqlTimeFormat),
4548
updatedAt: moment().utc().format(mysqlTimeFormat),
4649
usersId,

0 commit comments

Comments
 (0)