Laravel Migration With Sqlite Error: TypeSet Does Not Exist
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)
Answer
for set here you may use enum datatype. try below format in the migration file.
$table->enum('test', ['one', 'two', 'three']);
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS - Conditionally Load a Different Page
- → Make a Laravel collection into angular array (octobercms)
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
- → Validating fileupload(image Dimensions) in Backend Octobercms
- → OctoberCMS Fileupload completely destroys my backend
- → How do I call the value from another backed page form and use it on a component in OctoberCms