0% found this document useful (0 votes)
2 views2 pages

Migrations

The document contains three Laravel migration classes for creating database tables: 'properties', 'owners', and 'tenants'. Each migration defines the structure of the respective table, including fields and constraints, such as foreign keys and default values. The 'up' method creates the tables, while the 'down' method drops them if they exist.

Uploaded by

on k
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Migrations

The document contains three Laravel migration classes for creating database tables: 'properties', 'owners', and 'tenants'. Each migration defines the structure of the respective table, including fields and constraints, such as foreign keys and default values. The 'up' method creates the tables, while the 'down' method drops them if they exist.

Uploaded by

on k
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

<?

php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration


{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('properties', function (Blueprint $table) {
$table->id(); //primary key
$table->foreignId('owner_id')->constrained('owners')-
>cascadeOnDelete(); // Define foreign key constraint
$table->string('title');
$table->string('address1');
$table->string('address2');
$table->string('country');
$table->string('state');
$table->string('city');
$table->integer('pincode');
$table->integer('rent');
$table->string('description');
$table->string('status')->default('ACTIVE');
Stable->string('occupancy')->default('VACANT');
$table->decimal('lat', 7, 4);
$table->decimal('long', 7, 4);
$table->rememberToken();
$table->timestamps();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('properties');
}
};

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration


{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('owners', function (Blueprint $table) {
$table->id();
$table->string('fname');
$table->string('lname');
$table->string('email');
$table->string('password');
$table->timestamps();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('owners');
}
};

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration


{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('tenants', function (Blueprint $table) {

$table->id(); //primary key


// $table->foreignId('owner_id')->constrained('owners')-
>cascadeOnDelete(); // Define foreign key constraint
$table->string('name');
$table->string('contact');
$table->string('email');
$table->string('address');
$table->timestamps();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('tenants');
}
};

You might also like