51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?php
|
||
|
||
namespace App\Database\Migrations;
|
||
|
||
use CodeIgniter\Database\Migration;
|
||
|
||
class CreateReviewsTable extends Migration
|
||
{
|
||
public function up()
|
||
{
|
||
$this->forge->addField([
|
||
'id' => [
|
||
'type' => 'INT',
|
||
'unsigned' => true,
|
||
'auto_increment' => true,
|
||
],
|
||
'wisata_id' => [
|
||
'type' => 'INT',
|
||
'unsigned' => true,
|
||
],
|
||
'rating' => [
|
||
'type' => 'INT',
|
||
'constraint' => 1,
|
||
'comment' => '1–5 bintang',
|
||
],
|
||
'komentar' => [
|
||
'type' => 'TEXT',
|
||
'null' => true,
|
||
],
|
||
'created_at' => [
|
||
'type' => 'DATETIME',
|
||
'null' => true,
|
||
],
|
||
'updated_at' => [
|
||
'type' => 'DATETIME',
|
||
'null' => true,
|
||
],
|
||
]);
|
||
|
||
$this->forge->addKey('id', true);
|
||
$this->forge->addForeignKey('wisata_id', 'wisata', 'id', 'CASCADE', 'CASCADE');
|
||
|
||
$this->forge->createTable('reviews');
|
||
}
|
||
|
||
public function down()
|
||
{
|
||
$this->forge->dropTable('reviews');
|
||
}
|
||
}
|