I have a plugin that I call locations, which is primed with thousands of cities worldwide. The data takes days to compile from numerous sources, so for obvious reasons, I don't want to have to regenerate the data each time I initiate a plugin:refresh command to update the plugin. However, I wish to be able to make updates to the plugin, including but not limited to adding new fields to existing tables and adding new tables. As an example, I have the following model definition:
namespace Sokser\Locations\Updates;
use Schema;
use October\Rain\Database\Updates\Migration;
class CreatePointsOfInterestsTable extends Migration
{
public function up()
{
Schema::create('sokser_locations_points_of_interests', function($table)
{
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('name',128)->index();
$table->string('name_long',512)->index();
$table->float('latitude')->index();
$table->float('longitude')->index();
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('sokser_locations_points_of_interests');
}
}
I would like to add the following field to the table definition:
$table->integer('city_id')->unsigned()->nullable()->default(null)->index();
without deleting any of the current data. How can I do this? Additionally, how can I add a new table to the plugin so that it will install on a plugin:refresh, but not delete any of the existing content? For example, the following is an example of my version.yaml file:
1.0.1: First version of locations
1.0.3:
- Create Regions Table
- create_regions_table.php
- Create Countries Table
- create_countries_table.php
- Create Cities Table
- create_cities_table.php
- Create Ages Mappings Table
- create_ages_mappings_table.php
- Create Ages Table
- create_ages_table.php
- Create Airports Table
- create_airports_table.php
- Create Country Currencies Table
- create_country_currencies_table.php
- Create Currencies Table
- create_currencies_table.php
- Create Hubs Table
- create_hubs_table.php
- Create Languages Table
- create_languages_table.php
- Create Plugs Table
- create_plugs_table.php
- Create Tags Mappings Table
- create_tags_mappings_table.php
- Create Tags Table
- create_tags_table.php
- Create Timezones Table
- create_timezones_table.php
- Create Traveler Types Table
- create_traveler_types_table.php
- Create Types Mappings Table
- create_types_mappings_table.php
- Create Types Table
- create_types_table.php
- Create Continents Table
- create_continents_table.php
- Create Country Plugs Table
- create_country_plugs_table.php
- Create Country Languages Table
- create_country_languages_table.php
- Create City Prices Table
- create_city_prices_table.php
1.0.4:
- Create Points Of Interest Table
- create_points_of_interests_table.php
I want to add the tables specified in version 1.0.4, but not affect anything from prior versions? Any hints?
Last updated