Skip to content

Commit

Permalink
fix #3000 メールメッセージや、カスタムエントリーのバックアップができない問題を改善
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuring committed Dec 30, 2023
1 parent 631acee commit b1215d8
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 4 deletions.
25 changes: 21 additions & 4 deletions plugins/baser-core/src/Service/BcDatabaseService.php
Original file line number Diff line number Diff line change
Expand Up @@ -924,8 +924,9 @@ public function getAppTableList($plugin = '', string $dbConfigKeyName = 'default
$db = ConnectionManager::get($dbConfigKeyName);
$tables = $db->getSchemaCollection()->listTables();
$plugins = Plugin::loaded();
$list = [];
$prefix = $db->config()['prefix'];

$checkNames = [];
foreach($plugins as $value) {
$pluginPath = BcUtil::getPluginPath($value);
if (!$pluginPath) continue;
Expand All @@ -937,12 +938,28 @@ public function getAppTableList($plugin = '', string $dbConfigKeyName = 'default
foreach($files[1] as $file) {
if (!preg_match('/Create([a-zA-Z]+)\./', $file, $matches)) continue;
$tableName = Inflector::tableize($matches[1]);
$checkName = $prefix . $tableName;
if (in_array($checkName, $tables)) {
$list[$value][] = $tableName;
$checkNames[$value][] = $prefix . $tableName;
}
}

$list = [];
foreach($tables as $table) {
$hasTablePluginName = (function() use($checkNames, $table){
foreach($checkNames as $plugin => $value) {
foreach($value as $checkName) {
$singularize = Inflector::singularize($checkName);
if (preg_match('/^(' . preg_quote($checkName, '/') . '|' . preg_quote($singularize, '/') . ')/', $table)) {
return $plugin;
}
}
}
return false;
})();
if($hasTablePluginName) {
$list[$hasTablePluginName][] = $table;
}
}

Cache::write('appTableList.' . $dbConfigKeyName, $list, '_bc_env_');
if ($plugin) {
return (isset($list[$plugin]))? $list[$plugin] : [];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php
declare(strict_types=1);

use BaserCore\Database\Migration\BcMigration;

class CreateCustomEntries extends BcMigration
{
/**
* Up Method.
*
* More information on this method is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-up-method
* @return void
*/
public function up()
{
$this->table('custom_entries', [
'collation' => 'utf8mb4_general_ci'
])
->addColumn('custom_table_id', 'integer', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('parent_id', 'integer', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('name', 'text', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('title', 'string', [
'default' => null,
'limit' => 255,
'null' => true,
])
->addColumn('level', 'integer', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('lft', 'integer', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('rght', 'integer', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('creator_id', 'integer', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('status', 'boolean', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('publish_begin', 'datetime', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('publish_end', 'datetime', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('published', 'datetime', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('created', 'datetime', [
'default' => null,
'limit' => null,
'null' => true,
])
->addColumn('modified', 'datetime', [
'default' => null,
'limit' => null,
'null' => true,
])
->create();
}

/**
* Down Method.
*
* More information on this method is available here:
* https://book.cakephp.org/phinx/0/en/migrations.html#the-down-method
* @return void
*/
public function down()
{
$this->table('custom_entries')->drop()->save();
}
}

0 comments on commit b1215d8

Please sign in to comment.