Answers for "laravel migration unique column"

PHP
1

laravel migration add unique column

Schema::table('tableName', function($table)
{
    $table->string('column-name')->unique(); //notice the parenthesis I added
});
Posted by: Guest on November-20-2020
1

composite unique between two columns laravel migration

public function up()
    {
        Schema::table('user_projects', function (Blueprint $table) {
            $table->unique(["user_id", "project_id"], 'user_project_unique');
        });
    }

    public function down()
    {
        Schema::table('user_projects', function (Blueprint $table) {
          $table->dropUnique('user_project_unique');
        });
    }
Posted by: Guest on October-09-2020
2

laravel create migration

php artisan make:migration add_votes_to_users_table --table=users

php artisan make:migration create_users_table --create=users
Posted by: Guest on June-27-2020
1

laravel migration alter column unique

$table->dropUnique('users_email_unique');
Posted by: Guest on August-31-2021
1

laravel set field unique

Schema::table('manufacturers', function($table)
{
    $table->string('name')->unique(); 
});
Posted by: Guest on March-31-2020

Code answers related to "laravel migration unique column"

Browse Popular Code Answers by Language