Migrations & database

Creation of a migration

This is an example of a migration that will create a table with the respective fields, for more info always check the official Laravel documentation.

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id('id');
            $table->string('slug');
            $table->string('name', 50);
            $table->string('surname', 50);
            $table->string('email', 100);
            $table->string('password', 255);
            $table->decimal('internal_cost')->nullable();
            $table->decimal('external_cost')->nullable();
            $table->enum('source', [UserSourceEnum::INTERNAL->value, UserSourceEnum::EXTERNAL->value]);
            $table->string('external_source')->nullable();
            $table->string('external_source_link')->nullable();
            $table->decimal('daily_availability')->nullable();
            $table->string('country')->nullable();
            $table->string('timezone')->nullable();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('users');
    }
};

Last updated