softDeletes() in migration not creating 'deleted_at' column
I'm working on a migration in Laravel 5.6 running on Homestead and after creating the following migration and running php artisan migrate the table create successfully, but there is no deleted_at column. The database is mySQL 5.7.24
I have no idea why the migration is not work. Any thoughts would be welcome.
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('sub_episodes', function (Blueprint $table) {
$table->increments('id');
$table->softDeletes();
$table->timestamps();
});
}
If this table already existed and the migration had run and then you added softDeletes() method you will not see the deleted_at column because the migration has already run. You will have to do a migrate:fresh to remove all the tables and re-run the migration. Warning! this will delete all of the data in your database.
@Drfraker this is a brand new migration and table, but I did run it and get a PHP warning due to an odd permissions issue with macOS Mojave and the directory mapping for Homestead using a Parallels provider. That said, I ran a php migrate:rollback, so the table was dropped. I shouldn’t still need to run a full `migrate:fresh in this scenario, right?
@jlrdw that’s a good idea. I think I already ran this with other columns and it worked, but because I was dealing with the odd bug I mentioned above I was trying a lot of things and don’t remember for sure. I’ll give this a shot and report back.
Ok. well I just tried adding the additional columns to my migration as you suggested @jlrdw and after running the migration EVERYTHING populated including the deleted_at column. I was dealing with a separate issue yesterday related to Homestead and macOS Mojave, so maybe they two were related. Regardless thank you both for your help.
Ok, THIS sucks. The problem is back. I realized I left out a column I needed so I rolled back the migration and added in the column:
$table->integer('episode_id')->unsigned();
After running the migration I get a bunch of errors like this:
PHP Warning: Unexpected character in input: ' in /home/vagrant/code/podman/database/migrations/2018_10_24_223202_create_sub_episodes_table.php on line 41
and the table is created with ALL the columns EXCEPT the one I added. I have no clue WHY this is happening. I think it's somehow related to my environment which is Homestead using a Parallels provider running in macOS Mojave. I've detailed that stuff in another issue here