2020-05-29 16:25:17 +00:00
|
|
|
<?php
|
2020-08-04 11:25:22 +00:00
|
|
|
|
2020-06-10 15:00:12 +00:00
|
|
|
/**
|
|
|
|
* Class AddCategories
|
|
|
|
* Creates categories table in database
|
|
|
|
*
|
|
|
|
* @copyright 2020 Podlibre
|
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
2020-05-29 16:25:17 +00:00
|
|
|
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
|
2020-06-10 15:00:12 +00:00
|
|
|
use CodeIgniter\Database\Migration;
|
2020-05-29 16:25:17 +00:00
|
|
|
|
|
|
|
class AddCategories extends Migration
|
|
|
|
{
|
|
|
|
public function up()
|
|
|
|
{
|
|
|
|
$this->forge->addField([
|
2020-05-31 19:15:52 +00:00
|
|
|
'id' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
2020-05-29 16:25:17 +00:00
|
|
|
],
|
2020-05-31 19:15:52 +00:00
|
|
|
'parent_id' => [
|
|
|
|
'type' => 'INT',
|
|
|
|
'unsigned' => true,
|
2020-05-29 16:25:17 +00:00
|
|
|
],
|
2020-05-31 19:15:52 +00:00
|
|
|
'code' => [
|
|
|
|
'type' => 'VARCHAR',
|
2020-10-29 15:45:19 +00:00
|
|
|
'constraint' => 32,
|
2020-05-31 19:15:52 +00:00
|
|
|
],
|
|
|
|
'apple_category' => [
|
|
|
|
'type' => 'VARCHAR',
|
2020-10-29 15:45:19 +00:00
|
|
|
'constraint' => 32,
|
2020-05-29 16:25:17 +00:00
|
|
|
],
|
|
|
|
'google_category' => [
|
2020-05-31 19:15:52 +00:00
|
|
|
'type' => 'VARCHAR',
|
2020-10-29 15:45:19 +00:00
|
|
|
'constraint' => 32,
|
2020-05-29 16:25:17 +00:00
|
|
|
],
|
|
|
|
]);
|
2021-04-02 17:20:02 +00:00
|
|
|
$this->forge->addPrimaryKey('id');
|
2020-06-26 14:34:52 +00:00
|
|
|
$this->forge->addUniqueKey('code');
|
2020-05-29 16:25:17 +00:00
|
|
|
$this->forge->addForeignKey('parent_id', 'categories', 'id');
|
|
|
|
$this->forge->createTable('categories');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function down()
|
|
|
|
{
|
|
|
|
$this->forge->dropTable('categories');
|
|
|
|
}
|
|
|
|
}
|