diff --git a/README.md b/README.md index 5ecfca9..cb8e011 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/composer.json b/composer.json index a3d7af7..c655d0e 100644 --- a/composer.json +++ b/composer.json @@ -29,9 +29,6 @@ "phpunit/phpunit": "~5.0" }, "autoload": { - "classmap": [ - "src/migrations" - ], "psr-4": { "Ipalaus\\Geonames\\": "src/" } diff --git a/src/Commands/ImportCommand.php b/src/Commands/ImportCommand.php index 4e446da..118cbe3 100644 --- a/src/Commands/ImportCommand.php +++ b/src/Commands/ImportCommand.php @@ -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'); @@ -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 @@ -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.'), ); diff --git a/src/Eloquent/Country.php b/src/Eloquent/Country.php index b6546e5..861f4e6 100644 --- a/src/Eloquent/Country.php +++ b/src/Eloquent/Country.php @@ -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() diff --git a/src/Eloquent/Name.php b/src/Eloquent/Name.php index 02cd0e1..e149c73 100644 --- a/src/Eloquent/Name.php +++ b/src/Eloquent/Name.php @@ -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'); } } \ No newline at end of file diff --git a/src/Seeders/DatabaseSeeder.php b/src/Seeders/DatabaseSeeder.php index 03295b3..5cd4018 100644 --- a/src/Seeders/DatabaseSeeder.php +++ b/src/Seeders/DatabaseSeeder.php @@ -23,4 +23,13 @@ public function __construct(Importer $importer) $this->importer = $importer; } + /** + * Run the database seeds. + * + * @return void + */ + public function run() + { + + } } \ No newline at end of file diff --git a/src/migrations/2013_11_28_170337_create_geonames_names.php b/src/migrations/2013_11_28_170337_create_geonames_names_table.php similarity index 100% rename from src/migrations/2013_11_28_170337_create_geonames_names.php rename to src/migrations/2013_11_28_170337_create_geonames_names_table.php diff --git a/src/migrations/2013_11_28_170817_create_geonames_alternate_names.php b/src/migrations/2013_11_28_170817_create_geonames_alternate_names_table.php similarity index 100% rename from src/migrations/2013_11_28_170817_create_geonames_alternate_names.php rename to src/migrations/2013_11_28_170817_create_geonames_alternate_names_table.php diff --git a/src/migrations/2013_11_28_171326_create_geonames_countries.php b/src/migrations/2013_11_28_171326_create_geonames_countries_table.php similarity index 100% rename from src/migrations/2013_11_28_171326_create_geonames_countries.php rename to src/migrations/2013_11_28_171326_create_geonames_countries_table.php diff --git a/src/migrations/2013_11_28_172716_create_geonames_language_codes.php b/src/migrations/2013_11_28_172716_create_geonames_language_codes_table.php similarity index 100% rename from src/migrations/2013_11_28_172716_create_geonames_language_codes.php rename to src/migrations/2013_11_28_172716_create_geonames_language_codes_table.php diff --git a/src/migrations/2013_11_28_173418_create_geonames_admin_divisions.php b/src/migrations/2013_11_28_173418_create_geonames_admin_divisions_table.php similarity index 100% rename from src/migrations/2013_11_28_173418_create_geonames_admin_divisions.php rename to src/migrations/2013_11_28_173418_create_geonames_admin_divisions_table.php diff --git a/src/migrations/2013_11_28_173425_create_geonames_admin_subdivisions.php b/src/migrations/2013_11_28_173425_create_geonames_admin_subdivisions_table.php similarity index 100% rename from src/migrations/2013_11_28_173425_create_geonames_admin_subdivisions.php rename to src/migrations/2013_11_28_173425_create_geonames_admin_subdivisions_table.php diff --git a/src/migrations/2013_11_28_173636_create_geonames_hierarchies.php b/src/migrations/2013_11_28_173636_create_geonames_hierarchies_table.php similarity index 100% rename from src/migrations/2013_11_28_173636_create_geonames_hierarchies.php rename to src/migrations/2013_11_28_173636_create_geonames_hierarchies_table.php diff --git a/src/migrations/2013_11_28_173817_create_geonames_features.php b/src/migrations/2013_11_28_173817_create_geonames_features_table.php similarity index 100% rename from src/migrations/2013_11_28_173817_create_geonames_features.php rename to src/migrations/2013_11_28_173817_create_geonames_features_table.php diff --git a/src/migrations/2013_11_28_173936_create_geonames_timezones.php b/src/migrations/2013_11_28_173936_create_geonames_timezones_table.php similarity index 100% rename from src/migrations/2013_11_28_173936_create_geonames_timezones.php rename to src/migrations/2013_11_28_173936_create_geonames_timezones_table.php diff --git a/src/migrations/2013_11_28_174249_create_geonames_continents.php b/src/migrations/2013_11_28_174249_create_geonames_continents_table.php similarity index 100% rename from src/migrations/2013_11_28_174249_create_geonames_continents.php rename to src/migrations/2013_11_28_174249_create_geonames_continents_table.php diff --git a/src/migrations/2014_05_08_230644_geonames_timezones_new_columns.php b/src/migrations/2014_05_08_230644_geonames_timezones_new_columns_table.php similarity index 100% rename from src/migrations/2014_05_08_230644_geonames_timezones_new_columns.php rename to src/migrations/2014_05_08_230644_geonames_timezones_new_columns_table.php diff --git a/src/migrations/2014_06_09_204419_geonames_admin_divisions_longer_code.php b/src/migrations/2014_06_09_204419_geonames_admin_divisions_longer_code_table.php similarity index 100% rename from src/migrations/2014_06_09_204419_geonames_admin_divisions_longer_code.php rename to src/migrations/2014_06_09_204419_geonames_admin_divisions_longer_code_table.php diff --git a/src/migrations/2014_06_10_165833_geonames_defaults_and_nullables.php b/src/migrations/2014_06_10_165833_geonames_defaults_and_nullables_table.php similarity index 100% rename from src/migrations/2014_06_10_165833_geonames_defaults_and_nullables.php rename to src/migrations/2014_06_10_165833_geonames_defaults_and_nullables_table.php