GimmeMylanta's avatar

Converting MySQL to Laravel Migration

Hey Hey,

Im in the process of creating some migrations for a sample thing im writing, i have the original SQL table structure but im having a little trouble when it comes to the primary key, key, and constraint at the bottom.

I would really appreciate some help. The SQL is as follows;

CREATE TABLE `poll_options` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `poll_id` int(11) NOT NULL,
 `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
 `created` datetime NOT NULL,
 `modified` datetime NOT NULL,
 `status` enum('1','0') COLLATE utf8_unicode_ci NOT NULL DEFAULT '1',
 PRIMARY KEY (`id`),
 KEY `poll_id` (`poll_id`),
 CONSTRAINT `poll_options_ibfk_1` FOREIGN KEY (`poll_id`) REFERENCES `polls` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
0 likes
4 replies
GimmeMylanta's avatar

Hey @aurawindsurfing ... Thats what im having trouble with, is writing the bottom bits by hand.

This is what I have so far

$table->bigIncrements('id');
$table->bigIncrements('poll_id');
$table->string('name', 255);
$table->tinyInteger('status')->nullable(false)->default(1);
$table->timestamps();

But the rest i dont know how to do

Please or to participate in this conversation.