-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migration breaking with mysql database #7
Comments
It worked ok with the code below: <?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateActivityStreamsTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('feeds', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('feedable_type');
$table->bigInteger('feedable_id')->unsigned();
$table->unique(['feedable_id', 'feedable_type']);
$table->text('extra')->nullable();
$table->timestamps();
});
Schema::create('activities', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('actor_type');
$table->string('actor_id');
$table->text('actor_data')->nullable();
$table->string('verb');
$table->string('object_type');
$table->string('object_id');
$table->text('object_data')->nullable();
$table->string('target_type')->nullable();
$table->string('target_id')->nullable();
$table->text('target_data')->nullable();
$table->timestamps();
});
Schema::create('feed_activities', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('activity_id')->unsigned();
$table->bigInteger('feed_id')->unsigned();
$table->unique(['feed_id', 'activity_id']);
$table->text('extra')->nullable();
$table->timestamps();
$table->foreign('activity_id')
->references('id')
->on('activities')
->onDelete('cascade');
$table->foreign('feed_id')
->references('id')
->on('feeds')
->onDelete('cascade');
});
Schema::create('follows', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('follower_id');
$table->string('follower_type');
$table->string('followable_id');
$table->string('followable_type');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('follows');
Schema::dropIfExists('feed_activities');
Schema::dropIfExists('activities');
Schema::dropIfExists('feeds');
}
} |
Hey, can you send a PR for the change? Thanks |
I will try, I am learning to code with git yet... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On 8.0 version this line breaks in the commented line below:
Schema::create('feeds', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('feedable_type');
$table->string('feedable_id')->unsigned(); //As a string field it does not support unsigned
$table->unique(['feedable_id', 'feedable_type']);
$table->text('extra')->nullable();
$table->timestamps();
});
Probably because of this error the constraints also break with error:
SQLSTATE[HY000]: General error: 3780 Referencing column 'activity_id' and referenced column 'id' in foreign key constraint 'feed_activities_activity_id_foreign' are incompatible.")
The text was updated successfully, but these errors were encountered: