What is your whole structure for organizers?
You can after migration just run sql update and change status to those organizers.
Hi, I am using
php artisan make:migration add_status_to_organizers_table --table=organizers
to add a status column to my organizers model. I already have around 200 organizers in my live app. In my migration file I have
public function up()
{
Schema::table('organizers', function (Blueprint $table) {
$table->char('status', 1)->default('d');
});
}
public function down()
{
Schema::table('organizers', function (Blueprint $table) {
$table->dropColumn('status');
});
}
Is there any way that I can set it up so that when I run php artisan migrate it will look at each model and if the current date is older than todays date it will set the status to 'p'. Then any new organizers created after will have a default status of 'd'?
Of course you can use query builder to update your data in database. It's up to you.
But this "if the current date is older than todays date it will set the status to 'p'" so it means that all organizers in your current database should have set status to p?
Then just update status to p in all rows of organizers.
Please or to participate in this conversation.