Browse Source
Fix migration for SQLite.
SQLite does not support dropping foreign keys. However, it will cleanly replace the foreign key later in the migration if ignored.
pull/758/head
Dominik George
7 years ago
No known key found for this signature in database
GPG Key ID: B79A3C16A0C4F296
1 changed files with
8 additions and
2 deletions
-
database/migrations/20180515205626_change_messages_primary_key.php
|
|
|
@ -8,7 +8,10 @@ class ChangeMessagesPrimaryKey extends Migration |
|
|
|
public function up() |
|
|
|
{ |
|
|
|
$this->schema->table('messages', function(Blueprint $table) { |
|
|
|
$table->dropForeign(['user_id']); |
|
|
|
if ($this->schema->getConnection()->getDriverName() !== 'sqlite') { |
|
|
|
$table->dropForeign(['user_id']); |
|
|
|
} |
|
|
|
|
|
|
|
$table->dropPrimary('messages_pkey'); |
|
|
|
$table->primary(['user_id', 'jidfrom', 'id']); |
|
|
|
$table->foreign('user_id') |
|
|
|
@ -20,7 +23,10 @@ class ChangeMessagesPrimaryKey extends Migration |
|
|
|
public function down() |
|
|
|
{ |
|
|
|
$this->schema->table('messages', function(Blueprint $table) { |
|
|
|
$table->dropForeign(['user_id']); |
|
|
|
if ($this->schema->getConnection()->getDriverName() !== 'sqlite') { |
|
|
|
$table->dropForeign(['user_id']); |
|
|
|
} |
|
|
|
|
|
|
|
$table->dropPrimary('messages_pkey'); |
|
|
|
$table->primary(['user_id', 'id']); |
|
|
|
$table->foreign('user_id') |
|
|
|
|