So I have a users table that has a one-to-one relationship with a school_members table. I was messing around and rolled back my single last migration and migrated it back right after here’s the file:
use IlluminateDatabaseMigrationsMigration;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateSupportFacadesSchema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->string('jwtv')->default(null)->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->string('jwtv')->default('')->change();
});
}
};
now mind you my users table and school_members table are related via user id not jwtv, but this action caused me to lose data over at my school_members table and NOT the users table, those data were fine. also there’s many to one relationship between roles and users table via roles id, but roles table are fine. lastly this I do have onDelete('cascade') for the one-to-one relationship.
My goal is trying to understand this so it doesn’t happen to me in the future.