mirror of https://github.com/movim/movim
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.1 KiB
37 lines
1.1 KiB
<?php
|
|
|
|
use Movim\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
|
|
class ChangeMessagesPrimaryKey extends Migration
|
|
{
|
|
public function up()
|
|
{
|
|
$this->schema->table('messages', function (Blueprint $table) {
|
|
if ($this->schema->getConnection()->getDriverName() !== 'sqlite') {
|
|
$table->dropForeign(['user_id']);
|
|
}
|
|
|
|
$table->dropPrimary('messages_pkey');
|
|
$table->primary(['user_id', 'jidfrom', 'id']);
|
|
$table->foreign('user_id')
|
|
->references('id')->on('users')
|
|
->onDelete('cascade');
|
|
});
|
|
}
|
|
|
|
public function down()
|
|
{
|
|
$this->schema->table('messages', function (Blueprint $table) {
|
|
if ($this->schema->getConnection()->getDriverName() !== 'sqlite') {
|
|
$table->dropForeign(['user_id']);
|
|
}
|
|
|
|
$table->dropPrimary('messages_pkey');
|
|
$table->primary(['user_id', 'id']);
|
|
$table->foreign('user_id')
|
|
->references('id')->on('users')
|
|
->onDelete('cascade');
|
|
});
|
|
}
|
|
}
|