69 lines
1.6 KiB
PHP
69 lines
1.6 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Database\Migrations;
|
||
|
|
|
||
|
|
use CodeIgniter\Database\Migration;
|
||
|
|
|
||
|
|
class RemoveFileUrlAndThumbnailFromFigmaTables extends Migration
|
||
|
|
{
|
||
|
|
public function up()
|
||
|
|
{
|
||
|
|
if ($this->db->fieldExists('file_url', 'figma_files')) {
|
||
|
|
$this->forge->dropColumn('figma_files', 'file_url');
|
||
|
|
}
|
||
|
|
|
||
|
|
if ($this->db->fieldExists('thumbnail_url', 'figma_files')) {
|
||
|
|
$this->forge->dropColumn('figma_files', 'thumbnail_url');
|
||
|
|
}
|
||
|
|
|
||
|
|
if ($this->db->fieldExists('file_url', 'figma_file_versions')) {
|
||
|
|
$this->forge->dropColumn('figma_file_versions', 'file_url');
|
||
|
|
}
|
||
|
|
|
||
|
|
if ($this->db->fieldExists('thumbnail_url', 'figma_file_versions')) {
|
||
|
|
$this->forge->dropColumn('figma_file_versions', 'thumbnail_url');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public function down()
|
||
|
|
{
|
||
|
|
$fieldsFiles = [];
|
||
|
|
if (!$this->db->fieldExists('file_url', 'figma_files')) {
|
||
|
|
$fieldsFiles['file_url'] = [
|
||
|
|
'type' => 'TEXT',
|
||
|
|
'null' => true,
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
if (!$this->db->fieldExists('thumbnail_url', 'figma_files')) {
|
||
|
|
$fieldsFiles['thumbnail_url'] = [
|
||
|
|
'type' => 'TEXT',
|
||
|
|
'null' => true,
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
if (!empty($fieldsFiles)) {
|
||
|
|
$this->forge->addColumn('figma_files', $fieldsFiles);
|
||
|
|
}
|
||
|
|
|
||
|
|
$fieldsVersions = [];
|
||
|
|
if (!$this->db->fieldExists('file_url', 'figma_file_versions')) {
|
||
|
|
$fieldsVersions['file_url'] = [
|
||
|
|
'type' => 'TEXT',
|
||
|
|
'null' => true,
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
if (!$this->db->fieldExists('thumbnail_url', 'figma_file_versions')) {
|
||
|
|
$fieldsVersions['thumbnail_url'] = [
|
||
|
|
'type' => 'TEXT',
|
||
|
|
'null' => true,
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
if (!empty($fieldsVersions)) {
|
||
|
|
$this->forge->addColumn('figma_file_versions', $fieldsVersions);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|