Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Lara_Love's avatar

how can we add column to database on host cpanel

Hello how can to add column to table that is on host cpanel ? can we add column in phpmyadmin ? it's safe ?

0 likes
9 replies
Bookamat's avatar

@lovertohelp You probably have a couple of options.

  • create a new migration to add the new column and run the migration only
  • update the original migration - run migration

more manual way that might be the easiestfor your use is;

  • do the db changes in cpanel/phpmyadmin directly
  • but update the migration file locally as well so that your local is in sync for the future / tests

Example of the new migration

public function up()
{
    Schema::table('users', function (Blueprint $table) {
        $table->integer('created_by')->unsigned()->nullable();
    });
}

public function down()
{
    Schema::table('users', function (Blueprint $table) {
        $table->dropColumn('created_by');
    });
}
1 like
vincent15000's avatar

The best way is to create a new migration and add the needed fields.

public function up()
{
    Schema::table('users', function (Blueprint $table) {
        $table->foreignId('society_id')->nullable()->after('remember_token')->references('id')->on('societies');
        $table->boolean('admin')->after('society_id')->default(false)->index();
        $table->boolean('superadmin')->after('admin')->default(false);
        $table->boolean('active')->after('superadmin')->default(true)->index();
    });
}
Lara_Love's avatar

can we run php artisan migrate in cpanel ? how?

1 like
Lara_Love's avatar

now site is on host . can you show way without php artisan migrate i want add one column in 1 table without destroy data on database. i afraid that other data remove from database .

1 like
vincent15000's avatar
Level 63

@LoverToHelp You can migrate even if your app is on production, it won't remove any data if you have created the tables via the migration.

Anyway you have to save the database before any migration, migrate, and if it removes any data, you can restore the saved database.

jlrdw's avatar

@LoverToHelp before any migration on a live server, Backup your data first. Someone did this a while back and lost 6 months of data entry.

1 like

Please or to participate in this conversation.