So this is a newly created project and I haven’t touched any of the other files except the migrations I tried to add into the existing users table alongside with the laravel breeze package but to no avail
here is the content of the migration file:
<?php
use IlluminateDatabaseMigrationsMigration;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateSupportFacadesSchema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->date ('birth_date');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
//
});
}
};
then here is the terminal saying that it has been migrated:
C:xampphtdocslaravel8new_app>php artisan migrate
INFO Running migrations.
2024_06_25_105407_add_birthdate_to_users_table ...................................................................................... 47.34ms DONE
On another note whenever I register a new user the database seem to have no problem with the connection just the adding of new columns through migration.
I did a lot of refresh and rollbacks to my previous projects but no changes to the database still.
here is when I tried to create a lot of migration files just to make sure if any of them gets past
INFO Running migrations.
0001_01_01_000000_create_users_table ..................................................................................................... 1s DONE
0001_01_01_000001_create_cache_table ............................................................................................... 472.43ms DONE
0001_01_01_000002_create_jobs_table ...................................................................................................... 1s DONE
2024_06_25_085519_add_gender_and_birthdate_to_users .................................................................................. 0.11ms DONE
2024_06_25_085730_add_gender_and_birthdate_to_users_2 ................................................................................ 0.40ms DONE
2024_06_25_085737_add_gender_and_birthdate_to_users_3 ................................................................................ 0.11ms DONE
2024_06_25_085740_add_gender_and_birthdate_to_users_4 ................................................................................ 0.16ms DONE
there are no errors at all
Backup Camvids is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2
If you are using a MySQL database, then you have to configure Laravel to use that database, since the default is SQLite.
Update the .env
File
Open the .env
file (found in the root folder) in your Laravel project and update the database connection settings. Replace the existing SQLite settings with your MySQL database credentials.
You will to uncomment the below code, change the DB_CONNECTION
to mysql
and enter in your database data.
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database
DB_USERNAME=your_username
DB_PASSWORD=your_password
Update the config/database.php
File
Find the mysql
array in the connections
section and update the data to your database credentials.
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'your_database'),
'username' => env('DB_USERNAME', 'your_username'),
'password' => env('DB_PASSWORD', 'your_password'),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
Update the config/database.php
File (Optional)
Although this is not needed, I usually update the default value in the database.php file to the type of database I’m using in the project and remove the other types of connection.
'default' => env('DB_CONNECTION', 'mysql'),
Run the Migration
Finally, run the migration so the Laravel creates the tables in the MySQL database.
php artisan migrate