Merge pull request #2562 from sw-double/feature/tables-config

Respect database tables config.
This commit is contained in:
Samuel Georges 2017-01-13 06:08:27 +11:00 committed by GitHub
commit 17d0d5dc6b
4 changed files with 23 additions and 20 deletions

View File

@ -119,7 +119,7 @@ class UpdateManager
*/
public function update()
{
$firstUp = !Schema::hasTable('migrations');
$firstUp = !Schema::hasTable(Config::get('database.migrations'));
if ($firstUp) {
$this->repository->createRepository();
$this->note('Migration table created');
@ -337,7 +337,7 @@ class UpdateManager
}
}
Schema::dropIfExists('migrations');
Schema::dropIfExists(Config::get('database.migrations'));
return $this;
}

View File

@ -7,7 +7,7 @@ class DbJobs extends Migration
{
public function up()
{
Schema::create('jobs', function (Blueprint $table) {
Schema::create(Config::get('queue.connections.database.table'), function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->bigIncrements('id');
$table->string('queue');
@ -22,6 +22,6 @@ class DbJobs extends Migration
public function down()
{
Schema::dropIfExists('jobs');
Schema::dropIfExists(Config::get('queue.connections.database.table'));
}
}

View File

@ -7,7 +7,7 @@ class DbFailedJobs extends Migration
{
public function up()
{
Schema::create('failed_jobs', function (Blueprint $table) {
Schema::create(Config::get('queue.failed.table'), function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->text('connection');
@ -19,6 +19,6 @@ class DbFailedJobs extends Migration
public function down()
{
Schema::dropIfExists('failed_jobs');
Schema::dropIfExists(Config::get('queue.failed.table'));
}
}

View File

@ -10,24 +10,11 @@ use October\Rain\Database\Updates\Migration;
*/
class DbSystemTimestampFix extends Migration
{
protected $coreTables = [
'deferred_bindings',
'failed_jobs' => 'failed_at',
'system_files',
'system_event_logs',
'system_mail_layouts',
'system_mail_templates',
'system_plugin_history' => 'created_at',
'system_plugin_versions' => 'created_at',
'system_request_logs',
'system_revisions',
];
public function up()
{
DbDongle::disableStrictMode();
foreach ($this->coreTables as $table => $columns) {
foreach ($this->getCoreTables() as $table => $columns) {
if (is_int($table)) {
$table = $columns;
$columns = ['created_at', 'updated_at'];
@ -41,4 +28,20 @@ class DbSystemTimestampFix extends Migration
{
// ...
}
private function getCoreTables()
{
return [
'deferred_bindings',
Config::get('queue.failed.table') => 'failed_at',
'system_files',
'system_event_logs',
'system_mail_layouts',
'system_mail_templates',
'system_plugin_history' => 'created_at',
'system_plugin_versions' => 'created_at',
'system_request_logs',
'system_revisions',
];
}
}