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

add phone area data migration #82

Merged
merged 5 commits into from
Mar 21, 2021

Conversation

arwaawan3
Copy link
Contributor

Closes #76

PhoneArea::query()->insertOrIgnore([
[
'code' => 239,
'state_id' => 1,
Copy link
Member

Choose a reason for hiding this comment

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

We can't use an ID for State (#16). We have to look it up as we did with Country in the States migration to add the data:

This is because the State ID could be different in the application.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure no problem. I'll change it.

Copy link
Member

Choose a reason for hiding this comment

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

Thank you!

@drewroberts drewroberts marked this pull request as draft March 20, 2021 16:40
Comment on lines 1634 to 1636
->map(function (array $record) use ($now) {
$stateId = State::fromAbbreviation($record['state_abbreviation'])->getId();
unset($record['state_abbreviation']);
Copy link
Member

Choose a reason for hiding this comment

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

This is a slick implementation! :octocat:

Copy link
Contributor Author

@arwaawan3 arwaawan3 Mar 20, 2021

Choose a reason for hiding this comment

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

Thank you!

Comment on lines +51 to +57
public static function fromAbbreviation(string $abbreviation): self
{
/** @var State $result */
$result = static::query()->where('abbreviation', '=', $abbreviation)->firstOrFail();

return $result;
}
Copy link
Member

Choose a reason for hiding this comment

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

This is great! 🤩

@drewroberts
Copy link
Member

drewroberts commented Mar 20, 2021

@arwaawan3 Could you try breaking this out into 2 separate migrations and see if those last tests pass?

@drewroberts
Copy link
Member

Windows servers must have a limit on how many data rows can be added in a migration.

@arwaawan3
Copy link
Contributor Author

Oh ok I will split it.

@arwaawan3
Copy link
Contributor Author

@drewroberts I've split them in two files but I don't like the names of the two classes. If you any suggestions we can change them?

@drewroberts
Copy link
Member

I've split them in two files but I don't like the names of the two classes. If you any suggestions we can change them?

I think it's great for right now. I'm going to end up moving these files later from migrations to a datamigrations folder in the database folder. I can change it then. I'll also need to change the dates to be right after the migration of the table.

Copy link
Member

@drewroberts drewroberts left a comment

Choose a reason for hiding this comment

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

Thank you! 🐐

@drewroberts drewroberts marked this pull request as ready for review March 21, 2021 18:35
@drewroberts drewroberts merged commit 8d60d9d into main Mar 21, 2021
@drewroberts drewroberts deleted the omnia/feature/76-Phone-Area-Code-Data branch March 21, 2021 18:35
@arwaawan3
Copy link
Contributor Author

I've split them in two files but I don't like the names of the two classes. If you any suggestions we can change them?

I think it's great for right now. I'm going to end up moving these files later from migrations to a datamigrations folder in the database folder. I can change it then. I'll also need to change the dates to be right after the migration of the table.

Ok 👍

@arwaawan3
Copy link
Contributor Author

Closes #113

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Phone Area Code Data
3 participants