Category : migration

I get this error when I tried to migrate my foreign keys. Schema::create(‘people’, function (Blueprint $table) { $table->id(); $table->timestamps(); $table->unsignedBigInteger(‘PersonId’); $table->integer(‘PersonRole’); $table->string(‘PersonName’); $table->string(‘Email’)->unique(); $table->string(‘Password’); $table->string(‘Address’); $table->string(‘Gender’); $table->date(‘DoB’); }); Schema::create(‘flowers’, function (Blueprint $table) { $table->id(); $table->timestamps(); $table->unsignedBigInteger(‘FlowerId’); $table->string(‘Category’); $table->string(‘FlowerName’); $table->integer(‘FlowerPrice’); $table->string(‘Description’); $table->string(‘FlowerImage’); }); Schema::create(‘transactions’, function (Blueprint $table) { $table->id(); $table->timestamps(); $table->unsignedBigInteger(‘TransactionId’); $table->dateTime(‘Time’); $table->integer(‘PersonId’)->unsigned(); }); Schema::table(‘transactiondetails’, function ..

Read more

I have an existing application with a ton of cache files written using the Laravel file driver. These follow a specific directory and naming structure (e.g): cache/data/ 2d/ 6e/ 2d6eece558d9143286c4a08bb5757bb2cb6e9h9kf And if it has an expiry, the first 10 chars of the file is the expiry timestamp in unix time. 1605235030a:3:{s:3:"price";s:6:"342.99"…… I want to migrate ..

Read more

I’m working with Laravel 8 to develop my project and for this project I have created a migration which basically creates courses table: public function up() { Schema::create(‘courses’, function (Blueprint $table) { $table->id(); $table->unsignedBigInteger(‘user_id’); $table->foreign(‘user_id’)->references(‘id’)->on(‘users’)->onDelete(‘cascade’); $table->string(‘type’,10); $table->string(‘title’); $table->string(‘slug’); $table->string(‘price’,50); $table->text(‘description’); $table->text(‘body’); $table->string(‘images’,255); $table->string(‘tags’); $table->string(‘time’,15)->default(’00:00:00′); $table->integer(‘viewCount’)->default(0); $table->integer(‘commentCount’)->default(0); $table->timestamps(); }); } But when I want to insert ..

Read more

I have to use many to many relation in laravel this is tickets table and i cant change id type $table->increments(‘id’); $table->string(‘subject’); $table->integer(‘priority_id’)->unsigned(); $table->unsignedBigInteger(‘user_id’); $table->timestamps(6); $table->foreign(‘user_id’)->references(‘id’)->on(‘users’); and this is tag-ticket table $table->unsignedBigInteger(‘ticket_id’)->nullable(); $table->foreign(‘ticket_id’)->references(‘id’)->on(‘tickets’)->onDelete(‘set null’); SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table tag_ticket add constraint tag_ ticket_ticket_id_foreign foreign key (ticket_id) references ..

Read more

I am trying to migrate below function but it gives me same error everytime, i failed to find out the reason, even I tried the other syntax from documentation //up function public function up() { Schema::create(‘categories’, function (Blueprint $table) { $table->id(‘cat_id’); $table->string(‘cat_name’); $table->string(‘cat_desc’); $table->string(‘cat_image’); $table->timestamps(); }); Schema::create(‘sellers’, function (Blueprint $table) { $table->id(‘seller_id’); $table->string(‘seller_name’); $table->string(‘seller_desc’); $table->string(‘seller_image’); ..

Read more

I want to run a migration called articles which goes like this: public function up() { Schema::create(‘articles’, function (Blueprint $table) { $table->id(); $table->integer(‘user_id’)->unsigned(); $table->foreign(‘user_id’)->refrence(‘id’)->on(‘users’)->onDelete(‘cascade’); $table->string(‘title’); $table->string(‘slug’); $table->text(‘body’); $table->text(‘description’); $table->text(‘body’); $table->string(‘imageUrl’); $table->string(‘tags’); $table->integer(‘viewCount’)->default(0); $table->integer(‘commentCount’)->default(0); $table->timestamps(); }); } But I get this error: SQLSTATE[HY000]: General error: 1005 Can’t create table `gooyanet`.`#sql-1ce8_1d` (errno: 150 "Foreign key constraint is ..

Read more