Ad

Laravel Migration With Sqlite Error: TypeSet Does Not Exist

- 1 answer

TLDR;

Within SQLite, is there a better or alternative way to use "set"?

Full Information

I am trying to run a migration within Laravel, which works fine on MySQL. However, whenever trying to run the same migration on a testing database on SQLite, I run into the following error:

In Macroable.php line 103:

  Method Illuminate\Database\Schema\Grammars\SQLiteGrammar::typeSet does not exist.

I understand that the error is stating that "set" does not exist within SQLite. In order to fix this, I simply changed "set" to "string". However, this is suboptimal, as I would like to limit that field to specific values.

Within SQLite, is there a better or alternative way to use "set"?

Example:

Here is my migration that works with MySQL, but throws the typeSet error as seen above:

Schema::create('subscribers', function (Blueprint $table) {
    $table->bigIncrements('id');
    $table->set('test', ['one', 'two', 'three']);
    $table->timestamps();
});

Here is my temporary fix for the SQLite database:

Schema::create('subscribers', function (Blueprint $table) {
    $table->bigIncrements('id');
    $table->string('test', 255);
    $table->timestamps();
});

Thanks everyone for your comments and suggestions!

(Thanks @Dilip for your answer! For anyone else seeing this, if you want to know more about the difference between ENUM and SET, this answer was also helpful: MySQL enum vs. set)

Ad

Answer

for set here you may use enum datatype. try below format in the migration file.

$table->enum('test', ['one', 'two', 'three']);
Ad
source: stackoverflow.com
Ad