Closed fnagel closed 2 months ago
@fnagel thank you for your input. Did you add a foreign key to the package migrations? if you are thinking of enhancing the package performance you need to take into count that all the data is dynamically cached.
let me know please if my understanding is correct here above. Or maybe you are creating an external model with a relation to the country.
closed by lack of activity
@nnjeim Sorry for the late response. I was not able to get back to this project before.
Did you add a foreign key to the package migrations? if you are thinking of enhancing the package performance you need to take into count that all the data is dynamically cached. Or maybe you are creating an external model with a relation to the country.
Yes, but not for performance reasons but just to have a relation to another table. Maybe its more easy if I show you some code:
Schema::create('accounts', function (Blueprint $table) {
$table->id();
$table->timestamps();
$table->string('country', 2);
});
and in another migration:
Schema::table('world_countries', function (Blueprint $table) {
$table->index('iso2');
});
Schema::table('accounts', function (Blueprint $table) {
$table->foreign('country')->references('iso2')->on('world_countries')
->onDelete('cascade')->onUpdate('cascade');
});
Please note that I'm a experienced Symfony and TYPO3 developer but a Laravel beginner, so I might have done something wrong here.
@nnjeim Any feedback on this issue?
@nnjeim Any feedback on this issue?
Describe the bug If you create a model and have a foreignId in a for example countries id, when try to db:seed and error about truncate happend.
To Reproduce Create a model with a foreignId
$table->foreignId('country_id')->references('id')->on('countries');
php artisan db:seed --class=WorldSeeder
Error
Possible solution Same as for #15 but placed around here: https://github.com/nnjeim/world/blob/master/src/Actions/SeedAction.php#L144
Additional context Related to issue #15