Closed GlennBags closed 3 years ago
@GlennBags I think there's a bit of confusion here. You don't need to write a typical migration with Orbit, instead you use the schema
method on the Orbit model.
Ah, ok, I see that now, apologies. Will give it a go. Thanks for fast response :)
Yes, that seems to work so far.
Thoughts on seeding the data?
@GlennBags You should be able to use a normal seeder and use the model like you would any other, just call Model::create
or use a Factory
class.
Thanks for the help!
Added to my project today as was looking for a flat-file version of a db since I really only have one table that I would be creating. Can you please help on getting the migration working, and how exactly I'd be seeding it?
Additionally, since running migrations was still trying to connect to "mysql", I updated the config > databases >
'default' => 'orbit' // correct or no?
For the migration
up()
I have:Schema::create('products', function (Blueprint $table) { $table->string('identifier')->unique(); $table->string('name'); $table->string('decryption_key'); $table->string('api_key'); $table->string('api_end_point'); $table->json('api_data_config'); $table->json('api_registration_config'); });
Running it I get (did a remove of the previous run when I saw that it stating "exists"):
$ rm -rf content/products/ $ php artisan migrate Migrating: 2021_04_23_000000_create_products_table
Illuminate\Database\QueryException
SQLSTATE[HY000]: General error: 1 table "products" already exists (SQL: create table "products" ("identifier" varchar not null, "name" varchar not null, "decryption_key" varchar not null, "api_key" varchar not null, "api_end_point" varchar not null, "api_data_config" text not null, "api_registration_config" text not null))
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:678 674β // If an exception occurs when attempting to run a query, we'll format the error 675β // message to include the bindings with SQL, which will make this exception a 676β // lot more helpful to the developer instead of just the database's errors. 677β catch (Exception $e) { β 678β throw new QueryException( 679β $query, $this->prepareBindings($bindings), $e 680β ); 681β } 682β
10 database/migrations/2021_04_23_000000_create_products_table.php:49 Illuminate\Support\Facades\Facade::__callStatic("create")
32 artisan:37 Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))