Skip to content
This repository has been archived by the owner on Nov 26, 2021. It is now read-only.

Update to L5.1 #25

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ The import command downloads the needed files (configurable in the config file)

- `--country=XX`: downloads the specific country (ie. US, ES, FR...)
- `--development`: downloads a smaller names file (~10MB) very useful for development environments.
- `--essentials`: only seed the names, countries and continents tables.
- `--fetch-only`: only fetch the files but won't run the seeder. If you want to download the files and then be able to regenerate the tables while offline.
- `--wipe-files`: forces a delete of the old files.

```bash
$ php artisan geonames:import [--country="..."] [--development] [--fetch-only] [--wipe-files]
$ php artisan geonames:import [--country="..."] [--development] [--essentials] [--fetch-only] [--wipe-files]
```

Importing a production database can take a while. Main file is ~1GB and the seeder has to insert ~6M rows while creating indexes for some fields. In development environments, I highly recommend to use the `--development` option and keep complete imports to production. The final table sizes can also affect your local MySQL instance.
Expand Down
3 changes: 0 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
"phpunit/phpunit": "~5.0"
},
"autoload": {
"classmap": [
"src/migrations"
],
"psr-4": {
"Ipalaus\\Geonames\\": "src/"
}
Expand Down
16 changes: 11 additions & 5 deletions src/Commands/ImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public function fire()
{
$country = $this->input->getOption('country');
$development = $this->input->getOption('development');
$essentials = $this->input->getOption('essentials');
$fetchOnly = $this->input->getOption('fetch-only');
$wipeFiles = $this->input->getOption('wipe-files');

Expand Down Expand Up @@ -141,11 +142,15 @@ public function fire()
// finally seed the common seeders
$this->seedCommand('ContinentsTableSeeder');
$this->seedCommand('CountriesTableSeeder');
$this->seedCommand('AdminDivionsTableSeeder');
$this->seedCommand('AdminSubdivionsTableSeeder');
$this->seedCommand('HierarchiesTableSeeder');
$this->seedCommand('FeaturesTableSeeder');
$this->seedCommand('TimezonesTableSeeder');

if (! $essentials)
{
$this->seedCommand('AdminDivionsTableSeeder');
$this->seedCommand('AdminSubdivionsTableSeeder');
$this->seedCommand('HierarchiesTableSeeder');
$this->seedCommand('FeaturesTableSeeder');
$this->seedCommand('TimezonesTableSeeder');
}

// depending if we run a country, development or plain names we will run
// different seeders. Note that the langauge codes file is only
Expand Down Expand Up @@ -330,6 +335,7 @@ protected function getOptions()
return array(
array('country', null, InputOption::VALUE_REQUIRED, 'Downloads just the specific country.'),
array('development', null, InputOption::VALUE_NONE, 'Downloads an smaller version of names (~10MB).'),
array('essentials', null, InputOption::VALUE_NONE, 'Only seed the names, countries and continents tables.'),
array('fetch-only', null, InputOption::VALUE_NONE, 'Just download the files.'),
array('wipe-files', null, InputOption::VALUE_NONE, 'Wipe old downloaded files and fetch new ones.'),
);
Expand Down
7 changes: 7 additions & 0 deletions src/Eloquent/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ class Country extends Model {
*/
protected $primaryKey = 'iso_alpha2';

/**
* Indicates if the IDs are auto-incrementing.
*
* @var bool
*/
public $incrementing = false;

/* -( Relationships )-------------------------------------------------- */

public function continent()
Expand Down
2 changes: 1 addition & 1 deletion src/Eloquent/Name.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Name extends Model {

public function country()
{
return $this->belongsTo('Ipalaus\Geonames\Eloquent\Country');
return $this->belongsTo('Ipalaus\Geonames\Eloquent\Country', 'country_id', 'iso_alpha2');
}

}
9 changes: 9 additions & 0 deletions src/Seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,13 @@ public function __construct(Importer $importer)
$this->importer = $importer;
}

/**
* Run the database seeds.
*
* @return void
*/
public function run()
{

}
}